如果您的网站访问者禁用了 JavaScript,您该怎么办?
如果您的网站访问者禁用了 JavaScript,您会怎么做?你阻止他们吗?
What would you do if your site visitors disabled JavaScript? Do you block them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
理想情况下,您可以使用渐进式增强,这需要保证基本的用户体验,然后添加所有对于能够处理它们的浏览器来说,它会蓬勃发展。
Ideally, you would use progressive enhancement which entails guaranteeing a base user experience and then adding all the flourishes for browsers that can handle them.
你会降级 优雅地。
you would degrade gracefully.
确实优雅地降级了。如果这不再是一个选项(;-)),那么至少使用
标签通知他们。
Indeed degrade gracefully. If that's not an option (anymore ;-)) then at least notify them with utilizing a
<noscript>
tag.使用 NoScript 标签说“嘿,启用 Javascript 傻瓜!”
(请注意,此代码尚未准备好部署到您的网站。您可以将消息更改为比纯文本更合适的内容。)
Use the NoScript tag to say "Hey, Enable Javascript fool!"
(Please note that this is code is not ready deployment to your website. You can change the message to something more suitable than plain text.)
为了与
结合使用,我拥有需要 JS 才能与
class="js-required"
一起运行的所有元素。然后 CSS:
.js-required{display:none;}
页面加载时的 JS:
$('.js-required').css('display','block')
To couple with
<noscript>
I have all elements that require JS to function withclass="js-required"
.Then CSS:
.js-required{display:none;}
JS on page load:
$('.js-required').css('display','block')
如果 JavaScript 被禁用,您的网站应该做好一些准备,要么显示一条消息,表明您的网站在启用 JavaScript 的情况下工作得更好,要么解决它。
Your website should be somewhat prepared if JavaScript is disabled, either display a message that your website works better with JavaScript enabled or work-around it.
对于我构建的每个网站,我都会比较优雅降级的开发成本与吓跑约 2-3% 的受众而造成的收入损失。
不关心非 javascripters/Opera/等通常会获胜......
For every site I build, I compare the cost of development for degrading gracefully, versus the loss of income by scaring off ~2-3% of the audience.
Not caring about non-javascripters/Opera/etc usually wins...
你可以看看这个:
如何检测 JavaScript 是否被禁用?
you can check this out:
How to detect if JavaScript is disabled?
如果您的访问者不知道他们禁用了 JavaScript,一条简单的消息就会让他们知道应该启用它。
If your visitors didn't know they have JavaScript disabled, a simple message would let them know they should enable it.