W3cubDocs

/DOM

StyleSheet.ownerNode

ownerNode returns the node that associates this style sheet with the document.

Syntax

objRef = stylesheet.ownerNode 

Example

<html>
 <head>
  <link rel="StyleSheet" href="example.css" type="text/css" />
  <script>
   function stilo() {
    alert(document.styleSheets[0].ownerNode);
   }
  </script> 
 </head>
 <body>
   <button onclick="stilo()">ss</button>
 </body>
</html>
// displays "object HTMLLinkElement"

Notes

For HTML, ownerNode may be the corresponding LINK or STYLE element. For XML, it may be the linking processing instruction. For style sheets that are included by other style sheets, the value of this attribute is NULL.

Specification

DOM Level 2 Styles - STYLESHEET

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support 1 ? Yes ? Yes ?
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support Yes Yes ? Yes Yes ? ?

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/StyleSheet/ownerNode