Window location.hash property
- Previous Page assign()
- Next Page host
- Go to the Previous Level Window Location
Definition and Usage
location.hash
Property sets or returns the anchor part of the URL, including the hash symbol (#).
Tip:When using location.hash to set the anchor part, do not include the hash symbol (#).
Example
Example 1
Get the anchor part of the URL:
<a href="/js/js_strings.asp#part2">JavaScript Strings</a>
Example 2
Set anchor part:
location.hash = "part5";
Syntax
Return hash property:
location.hash
Set hash property:
location.hash = anchorname
Parameter
Parameter | Description |
---|---|
anchorname | The anchor part of the URL. |
Return value
Type | Description |
---|---|
String | The anchor part of the URL, including the hash mark (#). |
Browser Support
All Browsers Support location.hash
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page assign()
- Next Page host
- Go to the Previous Level Window Location