Noscript 标签、JavaScript 禁用警告和 Google 处罚

发布于 2024-07-24 05:49:56 字数 536 浏览 7 评论 0原文

当用户禁用 JavaScript 或使用 Noscript 等脚本阻止插件时,我一直使用 noscript 标签来显示警告。 如果 JavaScript 被禁用,网站将无法正常运行,并且用户可能无法在没有警告的情况下弄清楚网站无法运行的原因。

经过最新的 Google 算法洗牌后,我发现每日流量下降到前几个月的 1/3 左右。 我还看到在 SERPS 中排名第一或第二的页面从结果中消失。 在对网站管理员工具进行了一些调查后,我注意到“JavaScript”在关键字部分中被列为#16。 这是没有意义的,因为该网站与 JavaScript 无关,并且单词出现的唯一位置是在 noscript 标记之间的文本中。

看来 Google 现在正在包含 noscript 标签之间的内容并对其进行索引。 我不相信这种事以前发生过。 警告是三句话。 我想在网站的每个页面的顶部出现相同的三个句子可能会对搜索引擎优化产生破坏性影响。

您认为这会导致 SEO 出现问题吗? 并且,是否有任何其他方法可以向禁用 JavaScript 的用户提供警告,从而不会被搜索引擎索引或读取?

I have been using a noscript tag to show a warning when users have JavaScript disabled or are using script blocking plugins like Noscript. The website will not function properly if JavaScript is disabled and users may not figure out why it is not working without the warning.

After the latest Google algorithm shuffle, I have seen the daily traffic drop to about 1/3 of what it was in the previous months. I have also seen pages that were ranking #1 or #2 in the SERPS drop out of the results. After doing some investigating in webmaster tools, I noticed that "JavaScript" is listed as #16 in the keywords section. This makes no sense because the site has nothing to do with JavaScript and the only place that word appears is in the text between the noscript tags.

It seems that Google is now including and indexing the content between the noscript tags. I don't believe that this was happening before. The warning is three sentences. I'd imagine that having the same three sentences appearing at the top of every single page on the site could have a damaging effect on the SEO.

Do you think this could be causing a problem with SEO? And, is there any other method to provide a warning to users who have JavaScript disabled in a way that won't be indexed or read by search engines?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

蝶…霜飞 2024-07-31 05:49:57

我认为使用 不是一个好主意。 我听说当客户端位于阻止 JavaScript 的防火墙后面时,它是无效的 - 如果客户端的浏览器启用了 JavaScript,则 标记将不会激活,因为,就对于浏览器而言,JavaScript 在文档中是完全可操作的……

在我看来,更好的方法是让 JavaScript 隐藏所有可能的“无脚本”内容。

这是一个非常基本的示例:

...
<body>

    <script>
        document.body.className += ' js-enabled';
    </script>

    <div id="noscript">
        Welcome... here's some content...
    </div>

在样式表中:

body.js-enabled #noscript { display: none; }

更多信息:

I don't think using <noscript> is a good idea. I've heard that it is ineffective when the client is behind a JavaScript-blocking firewall - if the client's browser has JavaScript enabled the <noscript> tag won't activate, because, as far as the browser's concerned, JavaScript is fully operable within the document...

A better method IMO, is to have all would-be 'noscript' content hidden by JavaScript.

Here's a very basic example:

...
<body>

    <script>
        document.body.className += ' js-enabled';
    </script>

    <div id="noscript">
        Welcome... here's some content...
    </div>

And within your StyleSheet:

body.js-enabled #noscript { display: none; }

More info:

巷雨优美回忆 2024-07-31 05:49:57

另一个论坛上的有人提到使用图像作为警告。 在我看来,这将带来三个好处:

  1. 搜索引擎不会索引任何不相关的文本。
  2. 显示单个图像的代码比文本警告(在每个页面上加载)要小。
  3. 可以实施跟踪来确定图像被调用的次数,从而了解有多少访问者禁用或阻止了 JavaScript。

如果将其与 JP 提到的非 noscript 技术相结合,这似乎是最好的解决方案。

Somebody on another forum mentioned using an image for the warning. The way I see it, this would have three benefits:

  1. There wouldn't be any irrelevant text for search engines to index.
  2. The code to display a single image is less bulky than a text warning (which gets loaded on every page).
  3. Tracking could be implemented to determine how many times the image is called, to give an idea of how many visitors have JavaScript disabled or blocked.

If you combine this with something like the non-noscript technique mentioned by J-P, it seems to be the best possible solution.

静水深流 2024-07-31 05:49:57

只是想发布与此相关的有趣花絮。 对于我的网站,我最终做了与堆栈溢出使用的类似的操作,但添加了“了解更多”链接,因为我的用户不像该网站那样技术性强。

有趣的是,根据人们的建议,我的解决方案放弃了 noscript 标签,而是选择使用 javascript 隐藏消息 div。 但我发现如果firefox正在等待它的主密码,消息的这种隐藏就会被中断,所以我想我会回到noscript。

Just wanted to post an interesting tidbit related to this. For a site of mine I have ended up doing something similar to what stack overflow uses, but with the addition of a "find out more" link as my users are not as technical as this site.

The interesting part is that following advice of people aboce, my solution ditched the noscript tag, instead opting to hide the message divs with javascript. But I found that if firefox is waiting for its master password, this hiding of the message is interupted, so I think I will go back to noscript.

明月夜 2024-07-31 05:49:57

如果您选择基于替换 div 内容的解决方案(如果启用了 js,则 div 内容会更新)而不是使用 noscript 标记,请小心 google 如何看待这种做法:

http://support.google.com/webmasters/bin/answer .py?hl=en&answer=66353

我不确定 Google 是否会认为它具有欺骗性,但这是需要进一步考虑和研究的事情。 这是关于此问题的另一篇 stackoverflow 帖子:noscript google snapshot, the safe way

If you choose a solution based on replacing the div content (if js is enabled, then the div content gets updated) rather than using a noscript tag, be careful about how google views this practice:

http://support.google.com/webmasters/bin/answer.py?hl=en&answer=66353

I'm not sure google will consider it deceptive, but it's something to consider and research further. Here's another stackoverflow post about this: noscript google snapshot, the safe way

故事灯 2024-07-31 05:49:56

内容放在 HTML 的末尾处,然后使用 CSS 将其放置在浏览器窗口的顶部。 谷歌将不再认为它很重要。

Stack Overflow 本身就使用了这种技术 - 在此页面上查看源代码,您将在 HTML 末尾附近看到“最适合使用 JavaScript”警告,当您关闭 JavaScript 时,该警告会出现在页面顶部。

Put the <noscript> content at the end of your HTML, and then use CSS to position it at the top of the browser window. Google will no longer consider it important.

Stack Overflow itself uses this technique - do a View Source on this page and you'll see a "works best with JavaScript" warning near the end of the HTML, which appears at the top of the page when you switch off JavaScript.

不甘平庸 2024-07-31 05:49:56

并不意味着无意义的警告,例如:


不好了! 您没有启用 JavaScript! 如果你不启用 JS,你就完蛋了。 [关于如何在所有浏览器中启用 JS 的详细解释]

它的目的是让您提供尽可能多的内容,并礼貌地提及启用 JS 将提供对某些额外功能的访问。 您会发现基本上每个受欢迎的网站都遵循此准则。

<noscript> is not meant for meaningless warnings like:

<noscript>
Oh, no! You don't have JavaScript enabled! If you don't enable JS, you're doomed. [Long explanation about how to enable JS in every browser ever made]
</noscript>

It's meant for you to provide as much content as you can, along with a polite mention that enabling JS will provide access to certain extra features. You'll find that basically every popular site follows this guideline.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文