mozilla

Revision 373093 of Stylesheet.href

  • Revision slug: DOM/StyleSheet/href
  • Revision title: href
  • Revision id: 373093
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment 24 words addedStyleSheet/href DOM/StyleSheet/href

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.

This property is read-only in Firefox, Opera, Google Chrome, and Safari, and it is read/write in Internet Explorer.

Specification

href

{{ languages( {"zh-cn": "zh-cn/DOM/StyleSheet/href" } ) }}

Revision Source

<p>{{ DomRef() }}</p>
<h3 id="Summary" name="Summary">Summary</h3>
<p>Returns the location of the stylesheet.</p>
<h3 id="Syntax" name="Syntax">Syntax</h3>
<pre class="eval"><em>uri</em> = stylesheet.href 
</pre>
<h3 id="Parameters" name="Parameters">Parameters</h3>
<ul> <li><code>uri</code> is a string containing the stylesheet's URI.</li>
</ul>
<h3 id="Example" 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 id="Notes" 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 <code>NULL</code>.</p>
<p>This property is read-only in Firefox, Opera, Google Chrome, and Safari, and it is read/write in Internet Explorer.</p>
<h3 id="Specification" 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>
<p>{{ languages( {"zh-cn": "zh-cn/DOM/StyleSheet/href" } ) }}</p>
Revert to this revision