HTML <noscript> 标签不起作用

标签 html

根据定义<noscript>如果禁用 Javascript,则应显示其中的文本。

我使用 IE11 并禁用 JavaScript,只看到一个空白页面,根本没有任何消息。

<head>
<noscript>Javascript is disabled!</noscript>
<script>document.getElementById("demo").innerHTML="Script Enabled";</script>    
</head>
<p id="demo"> Test</p> 

我错过了什么吗?

最佳答案

根据您上面告诉我们的内容,您似乎输入/使用了正确的语法。

我在 Chrome 47 中尝试过,工作正常,也许在不同的浏览器中尝试一下,看看你的结果,或者确保你实际上已经关闭了 JavaScript。

示例:

<script>
document.write("Hello World!")
</script>
<noscript>Your browser does not support JavaScript!</noscript>

来自 W3Schools - here

你也可以这样做:

$(document).ready(function() {
  $('#noscript-description').css({
    'display' : 'none'
    
    // Just change the none to block to see the results
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<html>
  <body>
    <p id="noscript-description">This can be seen if you <b>DO NOT</b> have JavaScript enabled.</p>
    <!-- I have added in jQuery, if you never realised -->
  </body>
</html>

关于HTML <noscript> 标签不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34231292/

相关文章:

JavaScript:如何对变量的值求和并显示为 div?

javascript - 我如何找出导致页面不允许突出显示文本或右键单击的脚本?

javascript - html5 < Canvas > 帧率

css - Relative和Absolute定位相关的div定位问题

html - 为什么这个图像不调整到宽度大小,如果它在我指定宽度大小的容器内?

html - 如何使用转换对齐 HTML 中的图例?

html - 如何用一个 css 表引用多个 html 页面?

php - 使用 PHP 删除表格内联样式

html - 绝对定位元素不显示在溢出父级内

html - -moz-背景剪辑 : *text* in Mozilla