我是靠谱客的博主 飘逸歌曲,这篇文章主要介绍Chrome扩展页面动态绑定JS事件提示错误,现在分享给大家,希望可以做个参考。

问题描述:

当开发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;
}

最后

以上就是飘逸歌曲最近收集整理的关于Chrome扩展页面动态绑定JS事件提示错误的全部内容,更多相关Chrome扩展页面动态绑定JS事件提示错误内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(178)

评论列表共有 0 条评论

立即
投稿
返回
顶部