CSSImportRule:href 属性
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
CSSImportRule 接口的只读属性 href 返回由 @import at 规则指定的 URL。
解析后的 URL 将是关联样式表的 href 属性。
值
一个字符串。
示例
以下样式表包含一个 @import 规则。因此,CSS 规则列表中的第一个项目将是一个 CSSImportRule。href 属性返回导入样式表的 URL。
css
@import url("style.css") screen;
js
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].href); // 'style.css'
规范
| Specification |
|---|
| CSS Object Model (CSSOM)> # dom-cssimportrule-href> |
浏览器兼容性
Loading…