javascript - noscript 标签在不同浏览器中的处理方式

标签 javascript html css cross-browser noscript

我在任何地方都看不到对此的任何解释。

我只是想知道如果启用了 JS,浏览器会使用 noscript 标记内的数据生成什么

例如:

根据 HTML5 规范,允许在 head 标签内使用 noscript 标签。

<head>
<noscript>
<link rel="stylesheet" href="basic.css" type="text/css" media="all" />
</noscript>
</head>

我问这个问题的原因是我担心某些浏览器可能会将 noscript 标记视为文本(如果启用了 JS),因此它将加载/添加不必要的数据。

那么,浏览器实际上如何处理 noscript 标记?

谢谢。

最佳答案

The HTML Element defines a section of html to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser. Source.

还有

The noscript element represents nothing if scripting is enabled, and represents its children if scripting is disabled. It is used to present different markup to user agents that support scripting and those that don't support scripting, by affecting how the document is parsed. Source.

noscript 标签在浏览器中得到了很好的支持,据我所知,它没有偏离标准规范。

顺便说一下,如果您确实需要确保其在不同浏览器中的行为,您可以使用基于 Web 的浏览器测试工具,如 https://www.browserstack.com这将加快您的测试过程。

关于javascript - noscript 标签在不同浏览器中的处理方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39199798/

相关文章:

html - 自动换行不适用于 float 文本

html - 如何清理 Excel vba 中的对象?

javascript - 如何重命名时刻时区中的 precisionDiff 键?

javascript - 如何在 Javascript 中保存 zip 文件的二进制数据?

javascript - document.querySelectorAll() 函数不适用于所有元素

javascript - php/html - 三重嵌套引号

css - 排除 CSS 中的第一个元素

css - 停止 div 在 react 中插入另一个 div

html - 自动调整图像大小并缩小文件大小

javascript - 为什么JS代码 "var a = document.querySelector(' a[data-a=1 ]');"会报错?