【问题标题】:Cannot allow mixed content in FirefoxFirefox 中不允许混合内容
【发布时间】:2021-08-01 02:12:50
【问题描述】:

我已在控制台中粘贴以下代码尝试导入 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. 点击地址栏中的挂锁图标。
  2. 单击站点信息面板中的箭头。
  3. 点击暂时禁用保护

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

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

【问题讨论】:

    标签: javascript firefox firefox-developer-tools mixed-content


    【解决方案1】:

    出于安全原因,浏览器已停止允许通过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

    【讨论】:

      猜你喜欢
      • 2017-06-16
      • 1970-01-01
      • 2013-08-21
      • 2016-12-28
      • 2015-02-26
      • 2016-05-01
      • 2018-08-28
      • 2021-06-22
      相关资源
      最近更新 更多