不允许在 Firefox 中混合内容

Cannot allow mixed content in Firefox

我已将以下代码粘贴到控制台中以尝试导入 jQuery:

var jq = document.createElement("script");
jq.src = "http://code.jquery.com/jquery-3.6.0.min.js";
document.getElementsByTagName("head")[0].appendChild(jq);

但是显示的是这个输出:

Loading failed for the <script> with source "http://code.jquery.com/jquery-3.6.0.min.js".
Content Security Policy: The page's settings blocked the loading of a resource at http://code.jquery.com/jquery-3.6.0.min.js ("script-src").

看来我需要启用混合内容,正如the MDN article所说:

  1. Click the padlock icon in the address bar.
  2. Click the arrow in the Site Information panel.
  3. Click Disable protection for now.

但是没有暂时禁用保护按钮,就好像它从未尝试加载混合内容一样。

这是一个错误吗?为什么我不能在控制台中启用混合内容?

出于安全原因,浏览器不再允许通过 http 提供的内容来自通过 https 提供的网站。

所以您只需将“http://code.jquery.com/jquery-3.6.0.min.js”替换为“https://code.jquery.com/jquery-3.6.0.min.js”.

文档中有更多详细信息:https://developer.mozilla.org/en-US/docs/Web/Security/Mixed_content