Google chrome extension Google Chrome扩展清单版本2-执行初始化脚本
清单版本2内容安全策略不允许扩展运行内联脚本。这意味着我不能使用Google chrome extension Google Chrome扩展清单版本2-执行初始化脚本,google-chrome-extension,manifest,Google Chrome Extension,Manifest,清单版本2内容安全策略不允许扩展运行内联脚本。这意味着我不能使用 <script>Code Here</script> <button onclick="And here"> code在这里 当我使用清单版本1时,my popup.html以这种方式在其加载服务器上执行了一些代码: <body onload='init()'> 还是像这样 <script>init()</
<script>Code Here</script>
<button onclick="And here">
code在这里
当我使用清单版本1时,my popup.html以这种方式在其加载服务器上执行了一些代码:
<body onload='init()'>
还是像这样
<script>init()</script>
init()
现在我看到了唯一的方法——在popup.html中放置一个按钮,然后手动按下它进行初始化。我做错了什么?创建一个popup.js文件,并将脚本提取到此文件中,然后添加如下侦听器:
document.addEventListener('DOMContentLoaded', init());
然后将popup.js文件包含到popup.html文件中。@plavozont当然,请向上投票并接受答案。谢谢