--- title: StyleSheet.href slug: Web/API/StyleSheet/href tags: - DOM - Gecko - Gecko DOM Reference - StyleSheet translation_of: Web/API/StyleSheet/href --- <div> {{ApiRef}}</div> <h2 id="Summary" name="Summary">概要</h2> <p>スタイルシートの URI を返します。</p> <h2 id="Syntax" name="Syntax">構文</h2> <pre class="syntaxbox"><var>uri</var> = stylesheet.href </pre> <ul> <li><code>uri</code> : スタイルシートの URI</li> </ul> <h2 id="Example" name="Example">例</h2> <p>以下に示す HTML をローカルに配置して表示し、ボタンを押下した場合 <code>file:////C:/Windows/Desktop/example.css</code> などの様な文字列が表示されます。</p> <pre class="brush:html;highlight:[4,7,13]"><!DOCTYPE html> <html> <head> <link rel="stylesheet" href="example.css" /> <script> function sref() { alert(document.styleSheets[0].href); } </script> </head> <body> <button onclick="sref()">alert(document.styleSheets[0].href) を実行</button> </body> </html> </pre> <h2 id="Notes" name="Notes">注記</h2> <p>スタイルシートがリンクされたものである場合は、その {{HTMLElement("style")}} 要素の <code>href</code> 属性の示す位置が返ります。インラインスタイルのシートの場合の戻り値は <code>NULL</code> となります。</p> <p>このプロパティは Firefox 、 Opera 、 Google Chrome 、 Safari に於いては読取専用ですが、 Internet Explorer では読取 / 書込ともに可能となっています。</p> <h2 id="Specification" name="Specification">仕様書</h2> <ul> <li><a href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-StyleSheet-href">href </a></li> </ul>