您好,欢迎访问一九零五行业门户网

Chrome扩展页面动态绑定JS事件提示错误_javascript技巧

问题描述:
当开发chrome扩展时,页面的popup.html中需要js的时候,直接将js写在动态绑定js事件会提示:
refused to execute inline script because it violates the following content security policy directive: “script-src ‘self' chrome-extension-resource:”..
解决办法:
在popup.html中引用外部的js文件动态绑定js事件,例如:
复制代码 代码如下:
test.js中:
复制代码 代码如下:
var listbox = document.getelementbyid(showlist);
listbox.onclick=function(){
document.getelementbyid(player_sidebar).style.width = 100;
}
其它类似信息

推荐信息