aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/location/hash
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/location/hash
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/location/hash')
-rw-r--r--files/zh-cn/web/api/location/hash/index.html47
1 files changed, 47 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/location/hash/index.html b/files/zh-cn/web/api/location/hash/index.html
new file mode 100644
index 0000000000..0a0d45e220
--- /dev/null
+++ b/files/zh-cn/web/api/location/hash/index.html
@@ -0,0 +1,47 @@
+---
+title: 'Location: hash'
+slug: Web/API/Location/hash
+translation_of: Web/API/Location/hash
+---
+<div>{{ APIRef("Location") }}</div>
+
+<p><span class="seoSummary">{{domxref("Location")}} 接口的 <strong><code>hash</code></strong> 属性返回一个 {{domxref("USVString")}},其中会包含URL标识中的 <code>'#'</code> 和 后面URL片段标识符。</span></p>
+
+<p>这里 fragment 不会经过<a href="/en-US/docs/Glossary/percent-encoding">百分比编码</a>(URL编码)。如果 URL 中没有 fragment,该属性会包含一个空字符串,<code>""</code></p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox notranslate"><em>string</em> = <em>object</em>.hash;
+<em>object</em>.hash = <em>string</em>;
+</pre>
+
+<h2 id="Examples">Examples</h2>
+
+<pre class="brush: html notranslate">&lt;a id="myAnchor" href="/en-US/docs/Location.href#Examples"&gt;Examples&lt;/a&gt;
+&lt;script&gt;
+ var anchor = document.getElementById("myAnchor");
+ console.log(anchor.hash); // 返回'#Examples'
+&lt;/script&gt;</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', '#dom-location-hash', 'hash')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div class="hidden">本页面的兼容性表格是由结构化数据生成的。如果你愿意为这些数据做点贡献,请在 github <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> 检出代码,然后发送 pull request 给我们。</div>
+
+<p>{{Compat("api.Location.hash")}}</p>