当用户使用Internet Explorer登录并且禁用用户的javascript设置时,我想向用户显示一个警告。我尝试过使用<noscript>标签。我已经为测试它更改了我的javascript设置(enabled to disabled),但当我尝试它时,什么也没有显示。我该怎么做呢?下面是我的代码;
<script>
document.write("Hello World!")
</script>
<noscript>Sorry, your browser does not support JavaScript!</noscript>
<p>A browser without support for JavaScript will show the text inside the noscript element.</p>发布于 2015-02-10 23:25:35
这是个不错的选择。这是因为你的例子太简单了。浏览器自动将<script>和<noscript>标记包装在<head>中,这意味着当JS执行并写入"Hello world“时,<noscript>标记被隐藏,因为它在<head>中。
如果您手动将它们放在<body>中,它可以很好地工作:
<html><head></head>
<body>
<script>
document.write("Hello World!")
</script>
<noscript>Sorry, your browser does not support JavaScript!</noscript>
<p>A browser without support for JavaScript will show the text inside the noscript element.</p>
</body>
</html>
https://stackoverflow.com/questions/28435262
复制相似问题