URL.hash
URL
接口的 hash
属性返回一个 USVString
,其中会包含 URL 标识中的 '#'
和 fragment 标识符(fragment 即我们通常所说的 URL hash)。
这里 fragment 不会经过百分比编码(URL 编码)。如果 URL 中没有 fragment,该属性会包含一个空字符串 —— ""
.
备注: 此特性在 Web Worker 中可用
语法
string = object.hash; object.hash = string;
返回值
示例
var url = new URL('https://developer.mozilla.org/en-US/docs/Web/API/URL/href#Examples');
url.hash // Returns '#Examples'
规范
Specification |
---|
URL Standard # dom-url-hash |
浏览器兼容性
BCD tables only load in the browser
参考
- 所属的
URL
接口。