显示“无 Javascript” div,但不支持 google / facebook 共享服务

发布于 2024-09-12 15:34:05 字数 358 浏览 3 评论 0原文

我想在网站顶部附近显示一个 div,以建议未启用 JavaScript 的访问者启用 JavaScript。我想我已经通过使用 noscript 标签找到了一个好方法。

不幸的是,我发现这个解决方案不太理想,因为谷歌的索引器和 Facebook 的链接共享功能等服务。这些服务会抓取页面并读取 noscript div 中的文本作为页面摘要。发生这种情况是因为这些服务没有使用 JavaScript(显然)。

所以,我向大众提出的问题是:您更喜欢什么技术来避免“请启用您的 javascript”消息出现在 Google 的结果等中。

理想情况下,我希望找到解决此问题的最佳实践,但我很感兴趣聆听您过去成功或不成功使用的任何技巧。

谢谢!

I would like to show a div near the top of a site to suggest to visitors that do not have javascript enabled that they should enable their javascript. I thought I had found a good method by using the noscript tag.

Unfortunately I found that this solution was less than ideal because of services like Google's indexer and Facebook's link sharing functionality. These services scrape the page and read the text in the noscript div as the summary of the page. This happens because these services are not utilising javascript (obviously).

So, my question to the masses is: What techniques do you prefer for avoiding having your "please enable your javascript" messages appearing in Google's results etc.

Ideally, I'm hoping to discover the best practice for solving this issue, but am interested in hearing any techniques you have user successfully, or unsuccessfully in the past.

Thanks!

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

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

发布评论

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

评论(1

孤星 2024-09-19 15:34:05

在纯 HTML 场景中(如标记的那样),请考虑将消息放置在页面底部,并使用 CSS 将其明显放置在顶部。这应该将您的警告推到页面下方足够远的位置,以避免它出现在典型的搜索结果中。

如果您的 HTML 是由服务器脚本生成的,那么您可以根据客户端 UserAgent 有条件地呈现该元素。在这种情况下,一个好的搜索引擎用户代理列表会很方便。

In a pure HTML scenario (as tagged), consider placing your message at the bottom of the page, and using CSS to position it visibly at the top. This should push your warning far enough down the page as to avoid it showing up in typical search results.

If your HTML is generated by server script, then you may be able to conditionally present the element based on the client UserAgent. A good search engine user agent list would be convenient in this case.

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