Area coordsプロパティ

Area 对象参考手册Area オブジェクト

定義と使い方

coords プロパティは、ある領域の coords プロパティ値を設定または返します。

coords プロパティは、画像マップ内のクリック可能な領域の座標を記述します。

ヒント:領域の左上隅の座標は0,0です。

構文

areaObject.coords=value

coords の出力には以下の値を指定できます:

值 説明
x1,y1,x2,y2 shape プロパティが "rect" に設定されている場合、左上隅と右下隅の矩形の座標を指定します。
x,y,radius shape プロパティが "circle" に設定されている場合、円の中心座標と半径を指定します。
x1,y1,x2,y2,..,xn,yn shape プロパティが "poly" に設定されている場合、多角形の座標を指定します。最初と最後の座標が異なる場合は、ブラウザーは多角形を閉じる座標を追加する必要があります。


ブラウザサポート

Internet ExplorerFirefoxOperaGoogle ChromeSafari

すべての主要ブラウザが coords プロパティをサポートしています。


例

例

画像マップ内の "Venus" 領域の座標を返します:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
</head>
<body>

<img src="planets.gif.html" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm.html">
</map>
<p>金星の座標:
<script>
document.write(document.getElementById("venus").coords);
</script>
</p>

</body>
</html>

上記の例の出力結果:

金星の座標: 124,58,8

試してみる »


Area 对象参考手册Area オブジェクト その他の拡張