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

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -