【问题标题】:Allow inline javascript google chrome extension允许内联 javascript google chrome 扩展
【发布时间】:2019-06-14 18:24:15
【问题描述】:

我正在尝试从修改您的新标签页的扩展程序中执行此 js 代码。

<script>
    function myFunction() {
        document.getElementById("qnote-text").innerHTML = "⭕ ";
    }
</script>

但我在 chrome 控制台上总是遇到同样的错误:

Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self'. Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution.

它必须是内联的。

【问题讨论】:

标签: google-chrome google-chrome-extension content-security-policy


【解决方案1】:

您的错误消息说 google-chrome 扩展程序不允许内联脚本。所以,你必须做像&lt;script src="script.js"&gt;&lt;/script&gt;这样的外部脚本

【讨论】:

    猜你喜欢
    • 2021-04-08
    • 2013-05-20
    • 1970-01-01
    • 1970-01-01
    • 2019-03-02
    • 2020-11-16
    • 1970-01-01
    • 1970-01-01
    • 2018-04-02
    相关资源
    最近更新 更多