2012-01-14 103 views
0

在显示某些网站内的iframe时出现问题。 Live example of codeIframe不显示某些页面

这一个工程。

<article class='nobackground'> 
    <iframe src='http://en.wikipedia.org/wiki/<?php echo $myid ?>'></iframe> 
    </article> 

这一个不显示。 (也不会YouTube,谷歌或Facebook,但静态html似乎显示效果细腻)使用

<article class='nobackground'> 
    <iframe src='http://www.google.ie/search?tbm=isch&hl=en&source=hp&biw=1280&bih=679&q=<?php echo $myid ?>'></iframe> 
    </article> 

CSS:

iframe { 
     width: 100%; 
     height: 620px; 
     background: white; 
     border: 1px solid rgb(192, 192, 192); 
     margin: -1px; 
} 

article.fill iframe { 
     position: absolute; 
     left: 0; 
     top: 0; 
     width: 100%; 
     height: 100%; 
     border: 0; 
     margin: 0; 
     border-radius: 10px; 
     -o-border-radius: 10px; 
     -moz-border-radius: 10px; 
     -webkit-border-radius: 10px; 
     z-index: -1; 
} 
+2

请参阅[本文](http://stackoverflow.com/q/3838600/250517)X-Frame-Option标题的解释 – 2012-01-14 14:22:08

+0

Erm ...你为什么要做一个''? _“这里没什么好看的,离开....”_ – Wrikken 2012-01-14 14:55:54

回答

1

谷歌和其他许多人通过Javascript(使用top.location检测当前成帧)以及Grzegorz Grzybek(禁止为兼容浏览器设置帧)提及的X-Frame-Option标头禁止iframe内容。

如果你想捕捉内容,你必须编写一个可以执行file_get_content()或cURL调用来获取页面代码并稍微修改代码的解决方案页面(使URL绝对,删除不需要的脚本),然后将代码回显到本地页面。

1

不能iframe的谷歌或是因为X-框架,选项的其他站点发送通过与标题。您的浏览器尊重这一点,并拒绝显示您尝试链接的页面。