Document:styleSheetSets 属性

已弃用: 不再推荐使用该特性。虽然一些浏览器仍然支持它,但也许已从相关的 web 标准中移除,也许正准备移除或出于兼容性而保留。请尽量不要使用该特性,并更新现有的代码;参见本页面底部的兼容性表格以指导你作出决定。请注意,该特性随时可能无法正常工作。

非标准: 该特性是非标准的,请尽量不要在生产环境中使用它!

styleSheetSets 只读属性返回一个所有当前可用样式表集合的实时列表。

一个可用的样式表集合的列表。

示例

给定一个 ID 为“sheetList”的 <ul>(列表)元素,你可以使用下面的代码将所有可用样式表集合的名称填充到列表中:

js
const list = document.getElementById("sheetList");
const sheets = document.styleSheetSets;

list.textContent = "";

for (const sheet of sheets) {
  const item = document.createElement("li");
  item.textContent = sheet;
  list.appendChild(item);
}

备注

可用样式表集合的列表是通过以下方式构建的:按照文档中所有可用的样式表在 Document.styleSheets 属性中列出的顺序枚举,并将每个具有标题的样式表的 title 添加到列表中。列表中的重复项将被删除(使用区分大小写的比较)。

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
styleSheetSets
DeprecatedNon-standard

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.

参见