MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Revision 17613 of Stylesheet.href

  • Revision slug: DOM/stylesheet/href
  • Revision title: href
  • Revision id: 17613
  • Created:
  • Creator: Dria
  • Is current revision? No
  • Comment

Revision Content

{{template.DomRef()}}

Summary

Returns the location of the stylesheet.

Syntax

uri = stylesheet.href 

Parameters

  • uri is a string containing the stylesheet's URI.

Example

 // on a local machine: 
 <html> 
  <head> 
   <link rel="StyleSheet" href="example.css" type="text/css" /> 
   <script> 
    function sref() { 
     alert(document.styleSheets[0].href); 
    }
   </script> 
  </head> 
  <body> 
   <div class="thunder">Thunder</div>
   <button onclick="sref()">ss</button>
  </body> 
 </html>
// returns "file:////C:/Windows/Desktop/example.css

Notes

If the style sheet is a linked style sheet, the value of its attribute is its location. For inline style sheets, the value of this attribute is NULL.

Specification

href

Revision Source

<p>
{{template.DomRef()}}
</p>
<h3 name="Summary">Summary</h3>
<p>Returns the location of the stylesheet. 
</p>
<h3 name="Syntax">Syntax </h3>
<pre class="eval"><i>uri</i> = stylesheet.href 
</pre>
<h3 name="Parameters">Parameters </h3>
<ul><li><code>uri</code> is a string containing the stylesheet's URI.
</li></ul>
<h3 name="Example">Example </h3>
<pre> // on a local machine: 
 &lt;html&gt; 
  &lt;head&gt; 
   &lt;link rel="StyleSheet" href="example.css" type="text/css" /&gt; 
   &lt;script&gt; 
    function sref() { 
     alert(document.styleSheets[0].href); 
    }
   &lt;/script&gt; 
  &lt;/head&gt; 
  &lt;body&gt; 
   &lt;div class="thunder"&gt;Thunder&lt;/div&gt;
   &lt;button onclick="sref()"&gt;ss&lt;/button&gt;
  &lt;/body&gt; 
 &lt;/html&gt;
// returns "file:////C:/Windows/Desktop/example.css
</pre>
<h3 name="Notes">Notes </h3>
<p>If the style sheet is a linked style sheet, the value of its attribute is its location. For inline style sheets, the value of this attribute is NULL. 
</p>
<h3 name="Specification">Specification </h3>
<p><a class="external" href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-StyleSheet-href">href </a>
</p>
Revert to this revision