Anchor hash property
Definition and usage
hash
Property set or return href attribute value Anchor part.
The anchor part is the part after the hash (#) in the URL.
Note:Do not include the hash (#) when this property is used to set the anchor part.
See also:
JavaScript Reference Manual:location.hash property
Example
Example 1
Return the anchor part of the link:
var x = document.getElementById("myAnchor").hash;
Example 2
Change the anchor part of the link:
document.getElementById("myAnchor").hash = "newhashvalue";
Syntax
Return hash property:
anchorObject.hash
Indstil hash egenskab:
anchorObject.hash = anchorname
Egenskabsværdi
Værdi | Beskrivelse |
---|---|
anchorname | Definerer URL's ankerdel. |
Tekniske detaljer
Returværdi: | Strengværdi, der repræsenterer URL's ankerdel, inklusive stregen (#). |
---|
Browserstøtte
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |