Area coords 屬性

定義和用法
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",它 指定多邊形的的座標。如果第一個和最後一個 座標是不一樣的,流覽器必須加上一個閉合多邊形的座標 |
流覽器支持
所有主要流覽器都支持coords 屬性
實例
實例
返回圖像映射中 "Venus" 區域的的座標:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
</head>
<body>
<img src="planets.gif" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
<p>金星的座標:
<script>
document.write(document.getElementById("venus").coords);
</script>
</p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.com)</title>
</head>
<body>
<img src="planets.gif" width="145" height="126" usemap="#planetmap">
<map name="planetmap">
<area id="venus" shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
<p>金星的座標:
<script>
document.write(document.getElementById("venus").coords);
</script>
</p>
</body>
</html>
以上實例輸出結果:
金星的座標: 124,58,8
