TrustedScriptURL: toJSON() メソッド
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
メモ: この機能はウェブワーカー内で利用可能です。
toJSON()
は TrustedScriptURL
インターフェイスのメソッドで、格納されているデータの JSON 表現を返します。
構文
js
toJSON()
引数
なし。
返値
文字列で、格納されているデータの JSON 表現が入ります。
例
定数 sanitized
は、信頼型ポリシーによって作成されたオブジェクトです。toString()
メソッドは、サードパーティー製スクリプトを読み込むために安全に使用できる文字列を返します。
js
const sanitized = scriptPolicy.createScriptURL(
"https://example.com/my-script.js",
);
console.log(sanitized.toJSON());
仕様書
Specification |
---|
Trusted Types> # dom-trustedscripturl-tojson> |
ブラウザーの互換性
Loading…