DOMPointReadOnly: 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 Methode toJSON() der DOMPointReadOnly gibt ein Objekt zurück, das die JSON-Form des Punktobjekts liefert.

Syntax

js
toJSON()

Parameter

Keine.

Rückgabewert

Ein neues Objekt, dessen Eigenschaften auf die Werte im DOMPoint oder DOMPointReadOnly, auf dem die Methode aufgerufen wurde, gesetzt sind.

Beispiele

Dieses Beispiel erstellt ein DOMPoint-Objekt, das die obere linke Ecke des aktuellen Fensters in Bildschirmkoordinaten darstellt, und konvertiert dieses dann in JSON.

js
const topLeft = new DOMPoint(window.screenX, window.screenY);

const pointJSON = topLeft.toJSON();

Spezifikationen

Specification
Geometry Interfaces Module Level 1
# dom-dompointreadonly-tojson

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
toJSON()

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support