如果您的网站访问者禁用了 JavaScript,您该怎么办?

发布于 2024-08-18 20:42:58 字数 44 浏览 4 评论 0原文

如果您的网站访问者禁用了 JavaScript,您会怎么做?你阻止他们吗?

What would you do if your site visitors disabled JavaScript? Do you block them?

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

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

发布评论

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

评论(9

半边脸i 2024-08-25 20:42:58

理想情况下,您可以使用渐进式增强,这需要保证基本的用户体验,然后添加所有对于能够处理它们的浏览器来说,它会蓬勃发展。

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.

树深时见影 2024-08-25 20:42:58

确实优雅地降级了。如果这不再是一个选项(;-)),那么至少使用 标签通知他们。

Indeed degrade gracefully. If that's not an option (anymore ;-)) then at least notify them with utilizing a <noscript> tag.

〆一缕阳光ご 2024-08-25 20:42:58

使用 NoScript 标签说“嘿,启用 Javascript 傻瓜!”

<script type="text/javascript">
       alert("Hello World!");
</script>
<noscript> 
       Hey, Enable Javascript fool!
</noscript>

(请注意,此代码尚未准备好部署到您的网站。您可以将消息更改为比纯文本更合适的内容。)

Use the NoScript tag to say "Hey, Enable Javascript fool!"

<script type="text/javascript">
       alert("Hello World!");
</script>
<noscript> 
       Hey, Enable Javascript fool!
</noscript>

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

撩起发的微风 2024-08-25 20:42:58

为了与 结合使用,我拥有需要 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 with class="js-required".

Then CSS: .js-required{display:none;}

JS on page load: $('.js-required').css('display','block')

温柔一刀 2024-08-25 20:42:58

如果 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.

归属感 2024-08-25 20:42:58

对于我构建的每个网站,我都会比较优雅降级的开发成本与吓跑约 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...

留蓝 2024-08-25 20:42:58

如果您的访问者不知道他们禁用了 JavaScript,一条简单的消息就会让他们知道应该启用它。

<noscript>Please enable JavaScript in your browser</noscript>

If your visitors didn't know they have JavaScript disabled, a simple message would let them know they should enable it.

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