HTMLScriptElement: noModule 属性
HTMLScriptElement 接口的 noModule 属性是一个布尔值,用于指示脚本是否应在支持 ES modules 的浏览器中执行。实际上,这可以用于为不支持 JavaScript 模块的旧浏览器提供备用脚本。
它反映了 <script> 元素的 nomodule 属性。
值
一个布尔值,true 表示脚本不应在支持 ES modules 的浏览器中执行,否则为 false。
示例
html
<script id="el" nomodule>
// If the browser supports JavaScript modules, the following script will not be executed.
console.log("The browser does not support JavaScript modules");
</script>
js
const el = document.getElementById("el");
console.log(el.noModule); // Output: true
规范
| 规范 |
|---|
| HTML # dom-script-nomodule |
浏览器兼容性
加载中…