From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/url/hash/index.html | 60 +++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 files/zh-cn/web/api/url/hash/index.html (limited to 'files/zh-cn/web/api/url/hash') diff --git a/files/zh-cn/web/api/url/hash/index.html b/files/zh-cn/web/api/url/hash/index.html new file mode 100644 index 0000000000..e84ba5251e --- /dev/null +++ b/files/zh-cn/web/api/url/hash/index.html @@ -0,0 +1,60 @@ +--- +title: URL.hash +slug: Web/API/URL/hash +tags: + - API + - Hash + - URL +translation_of: Web/API/URL/hash +--- +
{{ APIRef("URL API") }}
+ +

{{domxref("URL")}} 接口的 hash 属性返回一个 {{domxref("USVString")}},其中会包含URL标识中的 '#' 和 fragment 标识符(fragment 即我们通常所说的 URL hash)。

+ +

这里 fragment 不会经过百分比编码(URL编码)。如果 URL 中没有 fragment,该属性会包含一个空字符串 —— "".

+ +

{{AvailableInWorkers}}

+ +

语法

+ +
string = object.hash;
+object.hash = string;
+
+ +

返回值

+ +

{{domxref("USVString")}}.

+ +

示例

+ +
var url = new URL('https://developer.mozilla.org/en-US/docs/Web/API/URL/href#Examples');
+url.hash // Returns '#Examples'
+ +

详情

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('URL', '#dom-url-hash', 'URL.hash')}}{{Spec2('URL')}}Initial definition
+ +

浏览器兼容

+ + + +

{{Compat("api.URL.hash")}}

+ +

参考

+ + -- cgit v1.2.3-54-g00ecf