Home > areaオブジェクト > lengthプロパティ
lengthプロパティ
areaオブジェクトのlengthプロパティはイメージマップのリンク数を返します。
書式 | document.links.length |
対応 | |
値 | イメージマップのリンク数 |
<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>