google chrome - Content JavaScript Not Executing in Content Script -
my chrome extension has content script adds div button. onclick js function defined button, however, never executes (defined in same content script), button nothing. why that?
contentscript.js
var msg = "click button <button onclick='test()'>test</button>"; var div = document.createelement( 'div' ); div.id = 'testdiv'; document.body.appendchild( div ); document.getelementbyid('testdiv').innerhtml = msg; function test() { alert('in test()'); // never gets here } manifest.json
"content_scripts": [ { "matches": [ "http://*/*", "https://*/*" ], "css": ["contentstyle.css"], "js": ["jquery-1.11.2.min.js", "contentscript.js"]
look @ official docs regarding policies. inline javascript strictly prohibited. docs explain how it. https://developer.chrome.com/extensions/contentsecuritypolicy
Comments
Post a Comment