語法
js
toJSON()
引數
無。
返回值
一個新的物件,其屬性值設定為呼叫該方法的 DOMQuad 中的值。
示例
此示例建立一個 DOMQuad,其中包含四個表示當前視窗角的 DOMPoint 物件(使用螢幕座標),然後將其轉換為 JSON。
js
const topLeft = new DOMPoint(window.screenX, window.screenY);
const topRight = new DOMPoint(
window.screenX + window.innerWidth,
window.screenY,
);
const bottomLeft = new DOMPoint(
window.screenX,
window.screenY + window.innerHeight,
);
const bottomRight = new DOMPoint(
window.screenX + window.innerWidth,
window.screenY + window.innerHeight,
);
const quad = new DOMQuad(topLeft, topRight, bottomRight, bottomLeft);
const quadJSON = quad.toJSON();
規範
| 規範 |
|---|
| Geometry Interfaces Module Level 1 # dom-domquad-tojson |
瀏覽器相容性
載入中…