CSSImportRule: href 屬性

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

CSSImportRule 介面的只讀 href 屬性返回由 @import at-rule 指定的 URL。

解析後的 URL 將是關聯樣式表的 href 屬性。

字串。

示例

以下樣式表包含一個單獨的 @import 規則。因此,CSS 規則列表中的第一項將是一個 CSSImportRulehref 屬性返回匯入樣式表的 URL。

css
@import "style.css" screen;
js
const myRules = document.styleSheets[0].cssRules;
console.log(myRules[0].href); // 'style.css'

規範

規範
CSS 物件模型 (CSSOM)
# dom-cssimportrule-href

瀏覽器相容性