The HTMLHyperlinkElementUtils.hash property returns a DOMString containing a '#' followed by the fragment identifier of the URL.
The fragment is not percent-decoded. If the URL does not have a fragment identifier, this property contains an empty string, "".
string = object.hash;
<a id="myAnchor" href="/en-US/docs/HTMLHyperlinkElementUtils.href#Examples">Examples</a>
<script>
var anchor = document.getElementById("myAnchor");
console.log(anchor.hash); // Returns '#Examples'
</script> | Specification | Status | Comment |
|---|---|---|
| HTML Living Standard The definition of 'HTMLHyperlinkElementUtils.hash' in that specification. | Living Standard | Initial definition |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | Yes
|
Yes | 22
|
No | No | No |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | Yes
|
Yes
|
Yes | 22
|
No | No | ? |
HTMLHyperlinkElementUtils interface it belongs to.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/hash