2012-01-14 73 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-框架,選項的其他站點發送通過與標題。您的瀏覽器尊重這一點,並拒絕顯示您嘗試鏈接的頁面。