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
支持 支持 支持 支持 支持

相關頁面

HTML 參考手冊:HTML <area> coords 屬性