Iframe不显示某些页面 [英] Iframe not displaying some pages
问题描述
有问题在iframe中显示一些网站。
实例代码
这一个很有用。
< article class ='nobackground' >
< iframe src ='http://en.wikipedia.org/wiki/< php echo $ myid?>'>< / iframe>
< / article>
这个不会显示。 (youtube,google或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;
背景:白色;
border:1px solid rgb(192,192,192);
margin:-1px;
}
article.fill iframe {
position:absolute;
剩下:0;
top:0;
宽度:100%;
身高:100%;
border:0;
保证金:0;
border-radius:10px;
-o-border-radius:10px;
-moz-border-radius:10px;
-webkit-border-radius:10px;
z-index:-1;
}
Google和其他许多人禁止iframing的内容通过Javascript(使用top.location检测当前帧)和Grzegorz Grzybek(禁止为符合标准的浏览器进行帧)提及的X-Frame-Option标题。
如果你想捕捉内容,你必须编写一个解决方案页面,它执行file_get_content()或cURL调用来获取页面的代码并修改(使URL绝对,删除不需要的脚本),然后将代码回显到本地页面。
Having issues displaying some websites within iframes. Live example of code
This one works.
<article class='nobackground'>
<iframe src='http://en.wikipedia.org/wiki/<?php echo $myid ?>'></iframe>
</article>
This one does not display. (neither will youtube, google or facebook, however static html seems to display fine)
<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 used:
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;
}
Google and many others forbid iframing of content through both Javascript (using top.location to detect current framing) and the X-Frame-Option header mention by Grzegorz Grzybek (which forbids framing for compliant browsers).
If you want to capture content you'll have to write a work-around page that does a file_get_content() or cURL call to fetch the code of the page and modify the code slightly (make URLs absolute, remove unwanted scripts) and then echo the code onto a local page.
这篇关于Iframe不显示某些页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!