显示"No Javascript" div,但不支持google/facebook共享服务 [英] Display a "No Javascript" div, but not to google / facebook share service

查看:94
本文介绍了显示"No Javascript" div,但不支持google/facebook共享服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在网站顶部附近显示一个div,以建议未启用javascript的访问者应启用其javascript.我以为使用noscript标签找到了一种好方法.

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.

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

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).

因此,我对大众的问题是:您希望采用哪种技术来避免在Google的搜索结果等中出现请启用您的JavaScript"消息.

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.

谢谢!

推荐答案

在纯HTML场景(如标记)中,请考虑将消息放置在页面底部,并使用CSS将其明显地放置在页面顶部.这样一来,您的警告就可以在页面上压得足够远,以免它出现在典型的搜索结果中.

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.

如果您的HTML是由服务器脚本生成的,则您可以基于客户端UserAgent有条件地显示该元素.在这种情况下,一个好的搜索引擎用户代理列表会很方便.

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.

这篇关于显示"No Javascript" div,但不支持google/facebook共享服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆