![]()
anchorオブジェクト(anchors配列)
anchorオブジェクトはハイパーテキストリンクの宛先情報(<a name>)です。
anchorオブジェクトの定義は、次の<a>タグが使用されます。
シンタックス
<a [href=locationOrURL] name="anchorName" [target="windowName"]> anchorText </a>
![]()
なお、anchorメソッドを使ってanchorオブジェクトを定義することができます。
- href=locationOrURL
 - ハイパーリンク先の場所またはURLです。
 - name="anchorName"
 - 文書にハイパーテキストのリンクターゲット用の名前を付けます。
 - target="windowName
 - 表示するウィンドウ名"windowName"です。
 - anchorText
 - アンカーとして表示するテキストです。
 anchorオブジェクトはdocumentオブジェクトのプロパティとして使用され、アンカー情報はanchors配列の中に入れます。文書の中に3つのアンカーがあれば、document.anchors[0]、document.anchors[1]、 document.anchors[2]で参照し、document.lengthの値は3です。
プロパティとなっているオブジェクト
- documentオブジェクト
 
プロパティ
- length: アンカーのリンク数を表わす
 
例
<script> document.write("この文書に含まれるアンカーの数は" + document.anchors.length + "個です。"); </script>
![]()
関連項目