StyleSheet:ownerNode 属性

Baseline Widely available

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

StyleSheet 接口的 ownerNode 属性返回和文档有关联的样式表的节点。

这通常是 HTML <link> 或者 <style> 元素,但是在 <?xml-stylesheet ?> 情况下,还可以返回一个处理指令节点

一个 Node 对象。

示例

html
<html lang="zh">
  <head>
    <link rel="stylesheet" href="example.css" />
  </head>
  <body>
    <button onclick="alert(document.styleSheets[0].ownerNode)">
      显示 example.css 的 ownerNode
    </button>
  </body>
</html>
// 显示“object HTMLLinkElement”。

备注

对于被其他样式表所包含的样式表(例如使用 @import 所包含的),此属性的值是 null

规范

Specification
CSS Object Model (CSSOM)
# dom-stylesheet-ownernode

浏览器兼容性

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
ownerNode

Legend

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

Full support
Full support