Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我能';无法使此自定义新选项卡扩展正常工作_Javascript_Html_Google Chrome Extension - Fatal编程技术网

Javascript 我能';无法使此自定义新选项卡扩展正常工作

Javascript 我能';无法使此自定义新选项卡扩展正常工作,javascript,html,google-chrome-extension,Javascript,Html,Google Chrome Extension,扩展不起作用,因为它说: 拒绝执行内联事件处理程序,因为它违反了以下内容安全策略指令:“script src'self'blob:filesystem:”。启用内联执行需要'unsafe inline'关键字、哈希('sha256-…')或nonce('nonce-…') 我曾尝试删除所有内联js,但它将body标记作为内联脚本 html: js: 1) 删除onload=“load()”,2)添加load()在js文件的开头,3)有关更多信息,请参见。1)删除onload=“load()”,2

扩展不起作用,因为它说:

拒绝执行内联事件处理程序,因为它违反了以下内容安全策略指令:“script src'self'blob:filesystem:”。启用内联执行需要'unsafe inline'关键字、哈希('sha256-…')或nonce('nonce-…')

我曾尝试删除所有内联js,但它将body标记作为内联脚本

html:

js:

1) 删除
onload=“load()”
,2)添加
load()在js文件的开头,3)有关更多信息,请参见。1)删除
onload=“load()”
,2)添加
load()在js文件的开头,3)有关更多信息,请参阅。
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body onload="load()">
    <h1>
    BACKGROUND OPTIONS
    </h1>

        <input type = "text" id = "text" value = "" />
        <br>
    <button id="save"">
    SAVE
    </button>
    <br>
    <h1> 
    I MAGE:
    </h1>
    <img id="imgid">
</body>
</html>
    <script src="options.js"></script>
</body>
</html>
{
  "manifest_version": 2,
  "name": "My Extension",
  "version": "3",
  "options_page": "options.html",
  "content_security_policy": "script-src 'self' 'unsafe-eval' ; object-src 'self'",
  "permissions": [
        "topSites",
        "chrome://favicon/",
        "unlimitedStorage",
        "topSites",
        "identity",
        "http://*/",
        "https://*/",
        "alarms",
        "tabs",
        "activeTab",
        "management",
        "storage",
        "webNavigation",
        "webRequest",
        "webRequestBlocking",
        "cookies",
        "contextMenus",
        "notifications",
        "background"
    ],
  "chrome_url_overrides" : {
    "newtab": "page.html"
  }
}
document.getElementById("save").onclick = function(){
    var select = document.getElementById("text");
    var text = select.value;
    localStorage["text"] = text;
    var image = document.getElementById("imgid");
    image.src = text;          
}

function load() {
var load = document.getElementById("text");
load.value = localStorage["text"];
document.body.style.background = localStorage["text"];
var image = document.getElementById("imgid");
image.src = localStorage["text"];
}