TrustedScriptURL: toString()-Methode

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Hinweis: Diese Funktion ist in Web Workers verfügbar.

Die toString()-Methode der TrustedScriptURL-Schnittstelle gibt einen String zurück, der sicher in eine Injection-Senke eingefügt werden kann.

Syntax

js
toString()

Parameter

Keine.

Rückgabewert

Ein String, der die bereinigte URL enthält.

Beispiele

Die Konstante sanitized ist ein Objekt, das über eine Trusted Types-Richtlinie erstellt wurde. Die toString()-Methode gibt einen String zurück, der sicher verwendet werden kann, um ein Skript eines Drittanbieters zu laden.

js
const sanitized = scriptPolicy.createScriptURL(
  "https://example.com/my-script.js",
);
console.log(sanitized.toString());

Spezifikationen

Specification
Trusted Types
# trustedscripturl-stringification-behavior

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
toString

Legend

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

Full support
Full support
No support
No support