位置:hash 属性
Location 接口的 hash 属性是一个字符串,其中包含一个 "#",后面跟着位置 URL 的片段标识符。如果 URL 没有片段标识符,则此属性包含一个空字符串 ""。
有关更多信息,请参阅 URL.hash。
值
字符串。
示例
假设用户已导航到 https://example.org#examples,以下代码将输出 #examples
js
const result = location.hash;
console.log(result);
规范
| 规范 |
|---|
| HTML # dom-location-hash-dev |
浏览器兼容性
加载中…