DOM & HTML
Trusted Types
Enforce safe HTML, script, and URL assignment to prevent Cross-Site Scripting (XSS).
Checking support...
Feature Not SupportedThis browser does not support the Trusted Types Web API feature. Try testing in a modern browser (such as Chrome, Edge, Safari, or Firefox).
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, '<')
});
}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