dkrks
dkrks

Reputation: 21

This document requires 'TrustedScript' assignment

I am trying to create an Outlook Add-In but I'm getting this error in the console:

This document requires TrustedScript assignment.

I tried these codes;

var unsafeHtml = "<p>This is <span>unsafe</span> HTML content.</p>";
var safeHtml = DOMPurify.sanitize(unsafeHtml, { RETURN_TRUSTED_TYPE: true });
document.getElementById("content").innerHTML = safeHtml;
if (window.trustedTypes && window.trustedTypes.createPolicy) { 
  window.trustedTypes.createPolicy('default', {
    createHTML: (string) => DOMPurify.sanitize(string, { 
      RETURN_TRUSTED_TYPE: true
    }),
    createScriptURL: string => string, 
    createScript: string => string, 
  });
}

I already tried everything but still couldn't resolve my problem. I installed DOMPurify and imported it to my project. I think it is about the authorization but I don't know how can I fix it?

Upvotes: 1

Views: 1082

Answers (0)

Related Questions