我在任何地方都看不到对此的任何解释。
我只是想知道如果启用了 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/