HTMLAnchorElement: свойство hash
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Свойство HTMLHyperlinkElementUtils.hash
возвращает строку, содержащую '#'
с последующим якорем URL.
Якорь URL закодирован. Если в URL нет якоря, это свойство содержит пустую строку (""
).
Значение
Строка.
Примеры
Получение якоря из ссылки
При наличии такой ссылки
html
<a id="myAnchor" href="/ru/docs/Web/API/HTMLAnchorElement/hash#примеры">
Примеры
</a>
можно получить из неё якорь таким образом:
js
const anchor = document.getElementById("myAnchor");
anchor.hash; // '#примеры'
Спецификации
Specification |
---|
HTML # dom-hyperlink-hash-dev |
Совместимость с браузерами
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
hash |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Смотрите также
- Интерфейс
HTMLAnchorElement
.