English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
hashProperty sets or returns the anchor part of the URL, including the hash mark (#).
If the URL does not have a fragment identifier, this property returns an empty string "".
Note:When using this property to set the anchor part, do not include the hash mark (#).
Return hash property:
location.hash
Set Hash Property:
location.hash = anchorName
var anchor = document.getElementById("myAnchor"); document.querySelector("#output").innerHTML = anchor.hash;Testen Sie heraus‹/›
hash-Eigenschaft wird von allen Browsern vollständig unterstützt:
Attribut | |||||
hash | Ja | Ja | Ja | Ja | Ja |
Wert | Beschreibung |
---|---|
anchorName | Ein String, der den Ankerbereich der URL spezifiziert |
Rückgabewert: | Ein String, der den Ankerbereich der URL darstellt, einschließlich des Hash-Symbols (#) |
---|
Ankerbereich festlegen:
var anchor = document.getElementById("myAnchor"); anchor.hash = "newFragement";Testen Sie heraus‹/›
Position Referenz:location.href-Eigenschaft
Position Referenz:location.hostname-Eigenschaft
Position Referenz:location.pathname-Eigenschaft
Position Referenz:location.protocol-Eigenschaft