mozilla

Revision 17615 of Stylesheet.href

  • Revision slug: DOM/stylesheet/href
  • Revision title: href
  • Revision id: 17615
  • Created:
  • Creator: Nickolay
  • Is current revision? No
  • Comment Reverted edit of Enajyram, changed back to last version by Dria

Revision Content

{{ 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>
{{ 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