Mixed Content Blocking导致Firefox23 无法显示iframe

来源:互联网 发布:unity3d awake start 编辑:程序博客网 时间:2024/06/07 23:34

转载自:http://blog.csdn.net/vking_wang/article/details/11659725

问题

前些天遇到了一个神奇的问题:有个网页包含了iframe,之前一直运行良好,但是Firefox升级到最新的23.0版本后,发现iframe内的内容变成空的了!查看元素iframe里只有。其他浏览器都没有问题。

原因

stackoverflow上有人说是因为使用了样式display:none;的缘故:

In google chrome the div contains an inline style of display:block (and a background-image). But in firefox the div it doesn’t have the display:block (only the background image). So, the problem is that teir scripts are not “showing” the map’s div.

see http://stackoverflow.com/questions/13790728/iframe-not-working-in-firefox

查了iframe src引用的网页源码,确实有这个样式!但是,把它去掉后,问题依旧。。。

后来偶然发现控制台上有打印:
[plain] view plain copy print?
已阻止读取混合活动内容 “http://10.235.59.215:8888/…….”
google之后发现Firefox23默认阻止读取混合活动内容!see Mixed Content Blocking Enabled in Firefox 23!

那么什么是混合活动内容呢?当一个HTTPS页面中包含HTTP内容时,即使主页面是经过SSL加密受HTTPS协议保护,但其中的HTTP内容可以被攻击者阅读或更改;这种HTTPS页面包含HTTP内容的情况,就被称为“混合内容”。

这种内容是不安全的,如果主页面是HTTPS,但iframe src引用HTTP内容,Firefox23默认会阻止这种内容的显式!

解决方案1

最直接的解决方法就是避免这种混合内容,将iframe src改为HTTPS即可。

解决方案2

但iframe引用的页面不支持HTTPS怎么办?可以让Firefox暂时不阻止:

点击地址栏的盾牌图标,选择Disable Protection on This Page;就会显示iframe;之后这个盾牌图标会变成一个感叹号图标。
解决方案3
但上述方案只对当前session有效,重启浏览器后又会被阻止。要让Firefox默认不阻止:
地址栏输入about:config进入配置页面,找到security.mixed_content.block_active_content,把它设为false。

0 0
原创粉丝点击