Area coords 属性

定义和用法

coords 属性设置或返回区域的 coords 属性的值。

coords 属性规定区域的 x 和 y 坐标。

coords 属性与 shape 属性一起用于规定区域的大小、形状和位置。

提示:区域左上角的坐标为 0,0。

提示:请使用 shape 属性设置或返回区域的 shape 属性值。

实例

例子 1

获取图像映射中特定区域的坐标:

var x = document.getElementById("venus").coords;

亲自试一试

例子 2

更改图像映射中特定区域的坐标:

document.getElementById("venus").coords = "129,161,10";

亲自试一试

语法

返回 coords 属性:

areaObject.coords

设置 coords 属性:

areaObject.coords = value

属性值

值 描述
x1, y1, x2, y2 如果 shape 属性设置为 "rect",则规定矩形左上角和右下角的坐标。
x, y, radius 如果 shape 属性设置为 "circle",则规定圆心坐标和半径。
x1, y1, x2, y2, .., xn, yn

如果 shape 属性设置为 "poly",则它规定多边形边缘的坐标。

如果第一个和最后一个坐标对不相同,浏览器必须添加最后一个坐标对才能闭合多边形。

技术细节

返回值: 字符串值,表示以逗号分隔的坐标列表。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持