1

JS code

function save_options() {


      var unesen_ip = document.getElementById('ip_add').value;
      var unesen_port = document.getElementById('port').value;
      localStorage.url = real_url;
      ...
    }

HTML code

<button onclick="save_options()">Save</button>

When I run my script I get this error

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

How can I make it "executable"? Thanks

user3758257
  • 69
  • 1
  • 7
  • When I Googled the error message you posted, it took me to a conversation here:http://stackoverflow.com/questions/24798669/chrome-extesion-refused-to-evaluate-a-string-as-javascript-because-unsafe-eval This hints that you can't use the inline JavaScript like you are using. – Jeremy J Starcher Aug 26 '14 at 12:40
  • Xan is right. See the item he references and you will find your answer. Also, read the Chrome App docs carefully, where this requirement is explained, or see my book. – Marc Rochkind Aug 26 '14 at 12:56

2 Answers2

1

It's a Chrome Content Security related issue....Visit following link detail information is given there it might solve your problem.....

https://developer.chrome.com/extensions/contentSecurityPolicy#JSExecution

Vishal
  • 747
  • 5
  • 25
0

Stupid me, tnx for your help guys.

document.getElementById("save").addEventListener("click", save_options, false);
user3758257
  • 69
  • 1
  • 7