How do I allow online javascript execution? (google extension)

Asked

Viewed 1,047 times

0

Hello, I was mounting an extension that received urls in a form and added new fields when a button was pressed. Running as normal html the code works, but when I run as extension it returns this error:

Refused to execute inline event handler because it violates the 
following Content Security Policy directive: "script-src 'self' blob: 
filesystem: chrome-extension-resource:". Either the 'unsafe-inline' 
keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required 
to enable inline execution.

HTML used:

<form id="formulario">
  <input type="url" class="campo" placeholder="endereço..." />
  <div onclick="sis_interface.novocampo();" class="novocampo"></div>
</form>

JAVASCRIPT used:

var sis_interface = {
  novocampo : function() {
    document.getElementById("formulario").innerHTML += '<input type="url" class="campo" placeholder="endereço..." />';
  }
}

Thanks in advance for the help.

  • Try looking at this topic: https://stackoverflow.com/questions/36622181/how-to-fix-chrome-extension-inline-javascript-invocation-error

  • Scripts are in the same domain as the page?

1 answer

-2


  • 2

    It would be more interesting if you summarize the answer here, because as much as it is from Soen, we want our posts here to be independent as much as possible, and your answer, if one day the author or the answer is erased, totally loses its meaning.

  • makes sense, in fact.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.