JavaScript入門講座

Home > locationオブジェクト > hashプロパティ

hashプロパティ

locationオブジェクトのhashプロパティはURLで指定した#以降の文字列を返します。

書式location.hash
対応Internet ExplorerFireFoxChromeSafariOpera
#以降の文字列
使用例URLで指定した#以降の文字列を表示。

<a id="Anchor" href="/test/docs/Location.href#hashtest">hashtest</a>
<script>
    var anchor = document.getElementById("Anchor");
    write(anchor.hash); //#hashtest
</script>