DOMQuad: toJSON() Methode
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Hinweis: Diese Funktion ist in Web Workers verfügbar.
Die DOMQuad
Methode
toJSON()
gibt eine
JSON Darstellung des DOMQuad
-Objekts zurück.
Syntax
toJSON()
Parameter
Keine.
Rückgabewert
Ein neues Objekt, dessen Eigenschaften den Werten des DOMQuad
entsprechen, auf dem die Methode aufgerufen wurde.
Beispiele
Dieses Beispiel erstellt ein DOMQuad
mit vier DOMPoint
Objekten, die die Ecken des aktuellen Fensters in Bildschirmkoordinaten darstellen, und konvertiert dies dann in JSON.
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();
Spezifikationen
Specification |
---|
Geometry Interfaces Module Level 1 # dom-domquad-tojson |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
toJSON() |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support