[英]Detection of javascript disable on a browser for a website
Sometime ago i disable javascript on my google chrome browser, and think how the website owner will detect if a user is disable javascript on that website, and i search on google and found answer of this question on stackoverflow. 不久前,我在Google chrome浏览器上禁用了javascript,并认为网站所有者将如何检测用户是否在该网站上禁用了javascript,然后我在google上搜索并在stackoverflow上找到了该问题的答案。 Here is the Link : click to show question .
这是链接: 单击以显示问题 。
After that i wrapped our all content of a page in the class pagecontainer
of the body tag something like this : 之后,我将页面的所有内容包装在body标签的class
pagecontainer
中,如下所示:
<body class="pagecontainer">
<noscript>
<style type="text/css">
.pagecontainer {display:none;}
</style>
<div class="noscriptmsg">
You don't have javascript enabled. Good luck with that.
</div>
</noscript>
//all page content is here
</body>
after that i disable javascript for this page, and tries to run this page, but i could't get the message which is wrapped within noscriptmsg
class. 之后,我为此页面禁用了javascript,并尝试运行此页面,但是我无法获得包裹在
noscriptmsg
类中的消息。 So plz help us to give the message which is given in the noscriptmsg
class if the user disable the javascript for this page. 因此,如果用户禁用了此页面的javascript,请plz帮助我们提供在
noscriptmsg
类中给出的消息。
Your CSS in the <noscript>
block makes the entire <body>
be hidden, and your <noscript>
tag is part of the <body>
. 您在
<noscript>
块中的CSS使整个<body>
被隐藏,而您的<noscript>
标签是<body>
。
You could change it to something like this: 您可以将其更改为以下内容:
<body>
<noscript>
<style type="text/css">
.pagecontainer {display:none;}
</style>
<div class="noscriptmsg">
You don't have javascript enabled. Good luck with that.
</div>
</noscript>
<section class=pagecontainer>
//all page content is here
</section>
</body>
An alternative is that you can put a <meta>
tag in your <noscript>
block to redirect the browser to your "please enable JavaScript" page. 另一种选择是,您可以在
<noscript>
块中放置一个<meta>
标记,以将浏览器重定向到“请启用JavaScript”页面。 That way your normal pages don't have to worry about it: 这样,您的普通页面就不必担心:
<!DOCTYPE html>
<html>
<head>
<noscript>
<meta http-equiv="refresh" content="0; url=http://your.domain/noscript.html">
</noscript>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.