当我尝试打开以下页面作为弹出窗口时,我遇到了以下消息:
Refused to load the script 'http://allinternetfinance.com/LetMeKnow/jquery-1.11.2.js' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval'
index.html:4 Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval'". Either the 'unsafe-inline' keyword, a hash ('sha256-anuyZ9J88P7xGyiuMhMfVwpc613qkiD1ZB3UusOLD6A='), or a nonce ('nonce-...') is required to enable inline execution."
html 是:
<html>
<head>
<script src="http://allinternetfinance.com/LetMeKnow/jquery-1.11.2.js";></script>
<script>
$( document ).ready(function() {
window.location.replace("http://localhost:8080/MembershipApp/index.html");
});
</script>
</head>
<body>
</body>
我得到的只是白色的小方 block ,而不是我试图将其重定向到的页面。
最佳答案
您首先需要做两件事:
- 下载 Jquery 并从扩展文件夹中加载它,或者根本不使用它。
- 将脚本标记的内容移至 .js 文件并引用它。
https://developer.chrome.com/extensions/contentSecurityPolicy
此外,弹出窗口似乎必须包含扩展文件,而是使用
chrome.tabs.create({ url: "http://localhost:8080/MembershipApp/index.html"})
关于javascript - 无法从弹出窗口运行 JavaScript 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30710239/