【问题标题】:Mixed content error vs warning混合内容错误与警告
【发布时间】:2017-02-04 02:19:14
【问题描述】:

什么决定了一个不安全的资源是否被阻止或加载并显示警告?

Chrome 53 的屏幕截图:

创建者:

(function(){var d=document.getElementsByTagName('IMG');for(var i=0,l=d.length;i<l;i++){d[i].setAttribute('src','http://placekitten.com/'+d[i].width+'/'+d[i].height)};}())

【问题讨论】:

  • 很奇怪,Chrome 似乎让第一个通过但阻止了其余的。它可能应该阻止所有这些。
  • @this.lau_ 不是这样。查看新屏幕截图。
  • 有没有办法复制这个问题? placekitten 图像是如何插入到 Wikipedia 主页中的?作为修复,可以使用“//placekiten.com/51/30”之类的协议相对 URL 插入它们,但这仍然无法解释为什么 Chrome 与警告和错误不一致。
  • 我添加了代码,在控制台中运行。

标签: google-chrome mixed-content


【解决方案1】:

被阻止的图像是那些img 指定了srcset 的图像。

img 具有srcset 时,Chrome 和 Firefox 会主动阻止混合内容。这里的src 是http 资源,而srcset 使用https。

Chromium Issue 402792 - Mixed content: &lt;img&gt; with empty srcset attribute should be active content

Mozilla Bug 1055750 - (srcset-mixed-content) Block mixed content &lt;img srcset&gt; and &lt;picture&gt;

【讨论】:

    猜你喜欢
    • 2016-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-19
    • 2013-04-03
    • 1970-01-01
    • 2018-11-08
    • 2015-02-11
    相关资源
    最近更新 更多