[英]Can I create a button to enable javascript
Is there any way to create a button to enable javascript if a user doesn't have it enabled? 如果用户未启用某个按钮,是否可以创建任何按钮来启用javascript?
If not, is there another way to enable javascript in the user's browser automatically when they visit our website? 如果没有,还有没有其他方法可以在用户访问我们的网站时自动在用户的浏览器中启用javascript?
Failing that, can I access the user's browser settings with permission and then enable javascript? 如果失败,我是否可以在获得许可的情况下访问用户的浏览器设置,然后启用javascript?
No. 没有。
If a user has disabled JavaScript then there is no way for a website to do anything (other then provide instructions (eg in <noscript>
)) to "help" them turn it on. 如果用户禁用了JavaScript,那么网站将无法做任何事情(然后提供说明(例如,在
<noscript>
))来“帮助”他们打开网站。
Given that people disabling JS are, increasingly, using third party tools (such as NoScript) to do so, providing instructions isn't likely to be helpful anyway. 鉴于禁用JS的人们越来越多地使用第三方工具(例如NoScript)来执行此操作,因此提供说明无论如何都无济于事。 If a user has disabled JavaScript, then it is safe to assume that they understand the consequences of doing so and are capable of finding the On switch for themselves.
如果用户禁用了JavaScript,则可以安全地假定他们了解这样做的后果,并且能够自己找到“打开”开关。
JavaScript can fail for other reasons though (such as a network problem while the JS file was downloading), so always be progressive and unobtrusive . JavaScript 可以失败但其他原因(如网络问题,而JS文件下载),所以始终是渐进的和不显眼 。
Have you considered using a <noscript>
tag? 您是否考虑过使用
<noscript>
标记?
<noscript>
<div class="bigRedWarningBoxInMiddleOfScreen">
Enable javascript pretty please
</div>
</noscript>
不,如果网页可以控制浏览器的安全性设置,那我们就该死了!
The only thing you can do is to check if JavaScript is disabled. 您唯一可以做的就是检查JavaScript是否已禁用。 If it is you can show a page that guides the user with enabling it.
如果是这样,则可以显示一个指导用户启用它的页面。
No but next best thing you could do is: 不,但是您可以做的下一件最好的事情是:
<noscript>
<div class="alert alert-error">Please enable JavaScript to use this site properly, here's <a href="http://www.enable-javascript.com/" target="_blank">how</a></div>
</noscript>
I believe that site detects which browser the user is using and gives directions accordingly. 我相信该网站会检测到用户正在使用哪个浏览器,并给出相应的指示。
Some people don't like noscript for some reason so you could do: 有些人由于某种原因不喜欢noscript,因此您可以这样做:
<div id="noscript">
<div class="alert alert-error">Please enable JavaScript to use this site properly, here's <a href="http://www.enable-javascript.com/" target="_blank">how</a></div>
</div>
and 和
document.getElementById('noscript').style.display = 'none';
But this might cause a flicker if your page size is large. 但是,如果您的页面很大,可能会导致闪烁。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.