Not TestedTesting not done, may not work properly
DOM & HTML

Trusted Types

Enforce safe HTML, script, and URL assignment to prevent Cross-Site Scripting (XSS).

Checking support...
Advertisement

Interactive Input Workspace

Ready for input

Web API Execution Output

Result output will be displayed here after processing...

Native JavaScript Code Example (Zero Libraries)

if (window.trustedTypes && trustedTypes.createPolicy) {
  const policy = trustedTypes.createPolicy('myPolicy', {
    createHTML: (string) => string.replace(/</g, '&lt;')
  });
}

About the Trusted Types Web API

Trusted Types API locks down DOM XSS sinks (like element.innerHTML) requiring TrustedHTML objects.

Specification:W3C & WHATWG Web API Standard
Sponsored Content