diff options
Diffstat (limited to 'files/zh-cn/web/api/stylesheet/href/index.html')
-rw-r--r-- | files/zh-cn/web/api/stylesheet/href/index.html | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/stylesheet/href/index.html b/files/zh-cn/web/api/stylesheet/href/index.html new file mode 100644 index 0000000000..d023340f78 --- /dev/null +++ b/files/zh-cn/web/api/stylesheet/href/index.html @@ -0,0 +1,53 @@ +--- +title: href +slug: Web/API/StyleSheet/href +translation_of: Web/API/StyleSheet/href +--- +<div>{{APIRef("CSSOM")}}</div> + +<h3 id="Summary" name="Summary">概述</h3> + +<p>返回当前样式表文件的URI地址.</p> + +<h3 id="Syntax" name="Syntax">语法</h3> + +<pre class="eval"><em>uri</em> = stylesheet.href +</pre> + +<h3 id="Parameters" name="Parameters">参数</h3> + +<ul> + <li><code>uri</code> 为一个字符串,包含了样式表文件的URI地址.</li> +</ul> + +<h3 id="Example" name="Example">例子</h3> + +<pre> // 在本机环境下 + <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> +// 弹出 "file:////C:/Windows/Desktop/example.css +</pre> + +<h3 id="Notes" name="Notes">备注</h3> + +<p>如果该样式表是一个外链样式表文件,则它的href属性值为样式表文件的URI. 但如果该样式表是一个内联样式表,则它的href属性值为<code>null</code>.</p> + +<p>该属性在Firefox, Opera, Google Chrome, Safari中为只读属性,在Internet Explorer中可读可写.</p> + +<h3 id="Specification" name="Specification">规范</h3> + +<p><a class="external" href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-StyleSheet-href">stylesheet.href </a></p> + +<p>{{ languages( {"en": "en/DOM/StyleSheet/href" } ) }}</p> |