トップページ > JavaScriptリファレンス > document.link.hash

★JavaScriptリファレンス

document.link.hash …… リンク先URLのハッシュ部分を参照する
Internet Explorer Google Chrome Safari Firefox Opera
広告

linkオブジェクトのhashプロパティは、リンク先URLのハッシュ部分(URLの#以降)を参照します。

■構文・引数・戻り値

構文
linkオブジェクト名.hash
戻り値
リンク先URLのハッシュ部分

■使用例

HTML + JavaScriptソース

<p>
<a id="samplelink" href="http://www.htmq.com:8000/js/index.php?q=javascript#link" target="_blank">
サンプルリンク
</a>
</p>
<script>
var linkObj = document.getElementById("samplelink");
document.write("<div>hrefは「" + linkObj.href + "」</div>");
document.write("<div>targetは「" + linkObj.target + "」</div>");
document.write("<div>protocolは「" + linkObj.protocol + "」</div>");
document.write("<div>hostnameは「" + linkObj.hostname + "」</div>");
document.write("<div>hostは「" + linkObj.host + "」</div>");
document.write("<div>portは「" + linkObj.port + "」</div>");
document.write("<div>pathnameは「" + linkObj.pathname + "」</div>");
document.write("<div>searchは「" + linkObj.search + "」</div>");
document.write("<div>hashは「" + linkObj.hash + "」</div>");
</script>
↓↓↓

ブラウザ上の表示

サンプルリンク

■関連項目

document.links.length …… ドキュメント内にあるリンクの数を参照する
document.link.href …… リンク先URLを参照する
document.link.target …… リンクのターゲット属性を参照する
document.link.protocol …… リンク先URLのプロトコルを参照する
document.link.hostname …… リンク先URLのホスト名を参照する
document.link.host …… リンク先URLのホスト情報を参照する
document.link.port …… リンク先URLのポート番号を参照する
document.link.pathname …… リンク先URLのパス名を参照する
document.link.search …… リンク先URLのサーチ情報を参照する
document.link.hash …… リンク先URLのハッシュ部分を参照する
広告
Sponsors
広告
MuuMuu Domain!
ドメイン取るならお名前.com
現役エンジニアのオンライン家庭教師【CodeCamp】
サイトに広告を掲載してお小遣いが稼げる!【A8.net】
Node.jsコース
はじめてのプログラミングコース
▲ページ先頭へ
HTMLクイックリファレンスについて
© HTMQ