Window location.hash property
- Forrige side assign()
- Næste side host
- Gå tilbage til forrige niveau Window Location
Definition and usage
location.hash
Property sets or returns the URL's anchor part, including the hash symbol (#).
Tip:When using location.hash to set an anchor part, do not include the hash symbol (#).
Example
Example 1
Get URL's anchor part:
<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 | Beskrivelse |
---|---|
anchorname | URL's anchor part. |
Return value
Type | Beskrivelse |
---|---|
Streng | URL's ankerdel, herunder hashtag (#). |
Browserstøtte
Alle browsere understøtter location.hash
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Forrige side assign()
- Næste side host
- Gå tilbage til forrige niveau Window Location