JavaScript入門講座

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

lengthプロパティ

areaオブジェクトのlengthプロパティはイメージマップのリンク数を返します。

書式document.links.length
対応Internet ExplorerFireFoxChromeSafariOpera
イメージマップのリンク数
使用例イメージマップのリンク数を表示する。

<html>
<head>
<title>JavaScript area length</title>
<script type="text/javascript">
function dispLinkNum(){
	alert("リンク数:"+ document.links.length);
}
</script>
</head>
<body>
<map name="area_test">
<area shape="rect" coords="16,17,96,93"
 href="http://www.google.co.jp/" alt="Googleへ">
<area shape="circle" coords="147,55,40"
 href="http://www.yahoo.co.jp/" alt="Yahooへ">
<area shape="poly" coords="53,111,16,182,96,182"
 href="http://jp.msn.com/" alt="MSNへ">
<area shape="poly" coords="147,104,106,150,147,190,192,150"
 href="http://www.excite.co.jp/" alt="Exciteへ">
</map>
<img src="imgarea.jpg" usemap="#area_test"
 border=0 width="200px" height="200px">
<form name="fm">
イメージマップのリンク数を表示する
<input type="button" value="確認" onclick="dispLinkNum()">
</form>
</body>
</html>		
						
関連メンバ
hostイメージマップ・リンクのホスト名とポート番号
hostnameイメージマップ・リンクのホストコンピュータ名
hrefイメージマップ・リンクのURL
pathnameイメージマップ・リンクのパス名
portイメージマップ・リンクのポート番号
protocolイメージマップ・リンクのプロトコル
targetイメージマップ・リンクのターゲット属性
searchイメージマップ・リンクの問合せ部分