Call a javascript function from popup page - chrome extension -
i'm trying build google chrome extension according parameters given in form - on popup page, manipulate url.
what way call javascript function , pass paramaters. pop up.html:
<button onclick="callit()">try it</button>
this js:
function callit(){ chrome.tabs.getselected(null, function (tab) { var theurl = tab.url; var newurl=theurl+'?asd=yes' chrome.tabs.update(tab.id, {url: newurl}); }); }
on debugger get:
refused execute inline event handler because violates following content security policy directive: "script-src 'self' chrome-extension-resource:".
so how should implement it?
docs google
content security policy
http://developer.chrome.com/extensions/contentsecuritypolicy.html#jsexecution
inline javascript not executed. restriction bans both inline blocks , inline event handlers (e.g.
<button onclick="...">
).
changes between version 1 , 2
http://developer.chrome.com/extensions/manifestversion.html#manifest-v1-changes
a content security policy set `script-src 'self' chrome-extension-resource:; object-src 'self' default. has variety of impacts on developers, described @ length in content_security_policy documentation.
Comments
Post a Comment