JavaScript入門講座

Home > anchorオブジェクト > lengthプロパティ

lengthプロパティ

anchorオブジェクトのlengthプロパティはアンカー数を返します。

書式document.anchors.length
ブラウザInternet ExplorerFireFoxChromeSafariOpera
アンカー数
使用例現在のページのアンカー数を表示する。

<html>
<head>
<title>JavaScript anchor length</title>
<script type="text/javascript">
function dispAnchorNum(){

	alert("アンカー数:" + document.anchors.length);	

}
</script>
</head>
<body>
<a name="#anchor1">アンカー1</a><br>
<a name="#anchor2">アンカー2</a><br>
<a name="#anchor3">アンカー3</a><br>
<form name="fm">
アンカー数を表示<br>
<input type="button" value="確認" onClick="dispAnchorNum()">
</form>
</body>
</html>
							
関連メンバ
nameアンカー名