Get to know MDN better
このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。
Since February 2026, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
メモ: この機能はウェブワーカー内で利用可能です。
createScript() methodは TrustedTypePolicy インターフェイスのメソッドで、 TrustedScript オブジェクトを TrustedTypePolicyFactory.createPolicy() で作成されたポリシーを使用して作成します。
このポリシーによって無害化された文字列です。
args 省略可TrustedTypePolicy で表される関数に渡される追加の引数です。
TrustedScript オブジェクトです。
TrustedTypePolicy に入力データで実行する関数がない場合に発生します。
以下の例では、潜在的に危険なスクリプトを含む文字列が createScript() の入力として使用されています。ポリシーはこのスクリプトを、実行される可能性のある注入先へ挿入する前に無害化できます。
| Trusted Types # dom-trustedtypepolicy-createscript |
Enable JavaScript to view this browser compatibility table.
This page was last modified on 2025年10月13日 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.