I'd like to add my .02 here.
(我想在这里添加我的.02。)
It's not 100% bulletproof, but I think it's good enough.(它不是100%防弹的,但我认为它足够好。)
The problem, for me, with the preferred example of putting up some sort of "this site doesn't work so well without Javascript" message is that you then need to make sure that your site works okay without Javascript.
(对于我来说,问题是出现一些“没有Java脚本,该站点无法正常运行”消息的首选示例,那么您需要确保您的站点在没有Java脚本的情况下可以正常工作。)
And once you've started down that road, then you start realizing that the site should be bulletproof with JS turned off, and that's a whole big chunk of additional work.(一旦走上了这条路,您就开始意识到该站点应该在关闭JS的情况下是防弹的,这是一大堆额外的工作。)
So, what you really want is a "redirection" to a page that says "turn on JS, silly".
(因此,您真正想要的是“重定向”到一个页面,该页面显示“傻傻地打开JS”。)
But, of course, you can't reliably do meta redirections.(但是,当然,您不能可靠地进行元重定向。)
So, here's the suggestion:(所以,这是建议:)
<noscript>
<style type="text/css">
.pagecontainer {display:none;}
</style>
<div class="noscriptmsg">
You don't have javascript enabled. Good luck with that.
</div>
</noscript>
...where all of the content in your site is wrapped with a div of class "pagecontainer".
(...您网站中的所有内容都被一个“ pagecontainer”类的div包裹。)
The CSS inside the noscript tag will then hide all of your page content, and instead display whatever "no JS" message you want to show.(然后,noscript标记内的CSS将隐藏您的所有页面内容,而是显示要显示的任何“ no JS”消息。)
This is actually what Gmail appears to do...and if it's good enough for Google, it's good enough for my little site.(这实际上就是Gmail的功能……如果对Google足够好,对我的小网站也足够好。)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…