加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

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

发布时间:2020-12-14 22:34:44 所属栏目:资源 来源:网络整理
导读:问题描述: 当开发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-re
问题描述:

当开发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事件,例如:
复制代码 代码如下:

<script type="text/javascript" charset="utf-8" src='test.js'></script>

test.js中:
复制代码 代码如下:

var listbox = document.getElementById("showlist");
listbox.onclick=function(){
document.getElementById("player_sidebar").style.width = 100;
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读