CSSNamespaceRule: thuộc tính namespaceURI

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2018.

Thuộc tính chỉ đọc namespaceURI của giao diện CSSNamespaceRule trả về một chuỗi chứa văn bản URI của không gian tên đã cho.

Giá trị

Một chuỗi chứa URI.

Ví dụ

Stylesheet bao gồm một không gian tên là quy tắc duy nhất. Do đó, CSSRule đầu tiên được trả về sẽ là CSSNamespaceRule. Giá trị của thuộc tính namespaceURI sẽ là 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'

Thông số kỹ thuật

Thông số kỹ thuật
CSS Object Model (CSSOM)
# dom-cssnamespacerule-namespaceuri

Tương thích trình duyệt