English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
hash属性はURLのアンchor部分(ハッシュを含む)を設定または返却します。
URLにフラグメント識別子がない場合、この属性は空文字列“”を返します。
注意:この属性を使用してアンchor部分を設定する場合、ハッシュ(#)を含めないでください。
ハッシュ属性の返却:
location.hash
ハッシュ属性の設定:
location.hash = anchorName
var anchor = document.getElementById("myAnchor"); document.querySelector("#output").innerHTML = anchor.hash;テストを見て‹/›
すべてのブラウザで完全にサポートされているhash属性:
属性 | |||||
hash | は | は | は | は | は |
値 | 説明 |
---|---|
anchorName | URLのアンchor部分を指定する文字列 |
返り値: | URLのアンchor部分を示す文字列、井戸端記号(#)を含む |
---|
アンchor部分の設定:
var anchor = document.getElementById("myAnchor"); anchor.hash = "newFragement";テストを見て‹/›
位置参照:location.href属性
位置参照:location.hostname属性
位置参照:location.pathname属性
位置参照:location.protocol属性