Get the anchor part of the URL:
<a href="/js/js_strings.html#part2">JavaScript Strings</a>
Try it Yourself »
Set the anchor part:
location.hash = "part5";
Try it Yourself »
The location.hash
property sets or returns the anchor part of a URL, including the hash sign (#).
When location.hash
is used to set the anchor part, do not include the hash sign (#).
Return the hash property:
location.hash
Set the hash property:
location.hash =
anchorname
Parameter | Description |
anchorname | The anchor part of a URL. |
Type | Description |
A string | The anchor part of the URL, including the hash sign (#). |
location.hash
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!