document.anchors

書式

document.anchors
document.anchors[参照番号]

説明

ドキュメント内の全てのアンカーオブジェクトの情報を保持するオブジェクトです。

サンプルコード [実行]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<script type="text/javascript"><!--
window.onload = function() {
var n = document.anchors.length;
document.getElementById("result").innerHTML = n;
}
// --></script>
</head>
<body>
<div id="result"></div>
<p><a name="section1">Sec.1</a> : test</p>
<p><a name="section2">Sec.2</a> : test</p>
<p><a name="section3">Sec.3</a> : test</p>
</body>
</html>