JavaScript入門講座

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

portプロパティ

areaオブジェクトのportプロパティはイメージマップ・リンクのポート番号を返します。ページのリンク情報は配列で格納されているのでIndex番号を指定してプロパティの値を取得します。

書式document.links[index番号].port
対応Internet ExplorerFireFoxChromeSafariOpera
イメージマップ・リンクのポート番号
使用例イメージマップ・リンクのポート番号を表示する。

<html>
<head>
<title>JavaScript area port</title>
<script type="text/javascript">
function dispPort(){
    for(var i=0 ; i < document.links.length ; i++){
        alert('ポート番号:' + document.links[i].port);
    }	
}
</script>
</head>
<body>
<map name="area_test">
<area shape="rect" coords="16,17,96,93"
 href="http://www.google.co.jp/index.html" alt="Googleへ">
<area shape="circle" coords="147,55,40"
 href="http://www.yahoo.co.jp/index.html" alt="Yahooへ">
<area shape="poly" coords="53,111,16,182,96,182"
 href="http://msn.co.jp/windows/index.html" 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="dispPort()">
</form>
</body>
</html>
						
関連メンバ
hostイメージマップ・リンクのホスト名とポート番号
hostnameイメージマップ・リンクのホストコンピュータ名
hrefイメージマップ・リンクのURL
lengthイメージマップ・リンク数
pathnameイメージマップ・リンクのパス名
protocolイメージマップ・リンクのプロトコル
targetイメージマップ・リンクのターゲット属性
searchイメージマップ・リンクの問合せ部分