HTML DOM Area coords attribute
Definition and Usage
coords coords property sets or returns the property value of an area.
coords attribute describes the coordinates of a clickable image map area.
Tip: upper-left area of the coordinates 0,0.
grammar
areaObject.coords=value
coords output can be the following values:
值 | 描述 |
---|---|
x1,y1,x2,y2 | 如果 shape 属性设置为"rect",它 指定的左上角和右下角的矩形坐标 |
x,y,radius | 如果 shape 属性设置为"circle",它 指定圆心坐标和半径 |
x1,y1,x2,y2,..,xn,yn | 如果 shape 属性设置为 "poly",它 指定多边形的的坐标。如果第一个和最后一个 坐标是不一样的,浏览器必须加上一个闭合多边形的坐标 |
Browser Support
All major browsers support coords attribute
Examples
Examples
Returns the coordinates of the image map "Venus" region:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>本教程(w3big.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>
Examples of the above output:
金星的坐标: 124,58,8
try it"
Area objects