CSSNamespaceRule:namespaceURI 属性
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2018年3月.
CSSNamespaceRule 的只读属性 namespaceURI 返回包含给定命名空间的 URI 文本的字符串。
值
包含 URI 的字符串。
示例
样式表包含一个命名空间作为唯一规则。因此返回的第一个 CSSRule 将是一个 CSSNamespaceRule。namespaceURI 属性的值将是 http://www.w3.org/1999/xhtml。
css
@namespace url("http://www.w3.org/1999/xhtml");
js
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].namespaceURI); // “http://www.w3.org/1999/xhtml”
规范
| Specification |
|---|
| CSS Object Model (CSSOM)> # dom-cssnamespacerule-namespaceuri> |
浏览器兼容性
Loading…