谷歌浏览器不允许IFRAME加载HTML文件



我有一个iframe,它在FF上运行良好,但在谷歌Chrome上似乎没有加载。

有人能告诉我为什么会发生这种事吗?

我的iframe

<iframe src="http://tripsketch.com/page?s=TheCavendish#!Id=1024&Name=London&Type=City&view=Attraction" height="700" width="990" frameborder="0" scrolling="no">
</iframe>

我测试了它,它在我端的chrome中运行良好。我的猜测是,你已经设置好了,所以包含iframe的页面是通过https访问的。如果页面是https,则不能在该页面上加载非https的iframe。它将导致"混合内容错误",出于安全目的,它不会加载。

它在FF中起作用,因为FF对这种安全限制更为宽松,而Chrome恰好对混合内容错误更为严格。

chrome版本27.xx&28.xxx在这个版本中,chrome有url重定向的问题,给出了空结果(302错误)。

为可能像我一样苦苦挣扎的人添加解决方案。我通过添加内容安全策略选项解决了这个问题。

<httpProtocol>
  <customHeaders>
    <add name="Content-Security-Policy" value="frame-ancestors https://www.<preferredwebsitedomain>.com" />
    <!-- Test this option as Chrome supports CSP now for Iframe opening-->
  </customHeaders>
</httpProtocol>

我有同样的问题,我不知道是因为什么,它认为是因为铬块的安全性,无论如何,我可以这样解决:

在您的html:中

<embed src='your_path' width='100%' height='100%'  type="application/pdf" />

经过多次调查和搜索,以下代码终于解决了问题:

<style type="text/css">
iframe {
  border: none;
  width: 100%;
  height: 500px;
}
@media (min-width: 1024px) {
  .content_viewport {
    border: 0px none;
    height: 900px;
width: 100%;
  }
}
@media (max-width: 1023px) {
  .content_viewport {
    border: 0px none;
    height: 900px;
width: 100%;  }
}
@media (min-width: 768px) {
  .content_viewport {
    border: 0px none;
    height: 900px;
width: 100%;  }
}
</style>
<div style=" overflow: hidden; margin: 15px auto; max-width: 880px;"><iframe class="content_viewport" scrolling="no" src="<Your URL>"></iframe>
<p>&nbsp;</p>
</div>

最新更新