TrustedScript: 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 Schnittstelle TrustedScript
gibt einen String zurück, der sicher in ein Injection Sink eingefügt werden kann.
Syntax
toString()
Parameter
Keine.
Rückgabewert
Ein String, der das bereinigte Skript enthält.
Beispiele
Die Konstante sanitized
ist ein Objekt, das über eine Trusted Types-Policy erstellt wurde. Die Methode toString()
gibt einen String zurück, der sicher als Skript ausgeführt werden kann.
const sanitized = scriptPolicy.createScript("eval('2 + 2')");
console.log(sanitized.toString());
Spezifikationen
Specification |
---|
Trusted Types # trustedscripturl-stringification-behavior |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
toString |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support