遇到以下错误时,我正在为Google chrome开发扩展程序:
拒绝执行内联事件处理程序,因为它违反了 以下内容安全策略指令:“ script-src'self' https://apis.google.com”。要么是'unsafe-inline'关键字,要么是哈希 ('sha256 -...')或现时('nonce -...')才能启用内联 执行。
我根本解决不了,如果您能帮助我,我将不胜感激。
manifest.js:
{
"name":"Pesquisa",
"version":"1.0",
"description":"teste",
"content_security_policy":"script-src 'self' https://apis.google.com; object-src 'self'",
"browser_action":{
"default_popup":"index.html"
},
"manifest_version":2
}
html:
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" ></script>
<div>
<input id="ent"type="text">
<div id="btn"><a href="#" onclick="op(this)">PESQUISAR</a></div>
</div>
js:
function op(e){
var txto = "https://www.google.com/search?q=" + document.getElementById("ent").value;
e.setAttribute('href',txto)
}