2014-02-11 116 views
5

我有以下代碼。我想在iframe中加載頁面。但它只顯示加載到iframe中。我只有在IE 11中有這個問題。在所有的瀏覽器中它工作正常。IE11內的iframe無法加載頁面

<iframe src="https://docs.google.com/viewer?url=http://localhost/test_energy/img/Sample.pdf&embedded=true" width="570" height="300" style="border: none;"> 
</iframe> 

回答

8

嘗試:

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE11"/> 
+9

這是什麼呢? – Doug

0

首先嚐試刪除分號 「;」 from your initial code

<iframe src="https://docs.google.com/viewer?url=http://localhost/test_energy/img/Sample.pdf&embedded=true" width="570" height="300" style="border: none;">;<- Remove this 

; < - 刪除該內容

然後嘗試應罰款

<iframe src="https://docs.google.com/viewer?url=http://tobi.oetiker.ch/lshort/lshort.pdf&embedded=true" width="570" height="300" style="border: none;"></iframe> 
+0

@matts在iframe之後沒有任何分號,實際上angle braket沒有采用那個y我給了<。現在我刪除了它。 – Ayesha

+0

好的在我的瀏覽器上註明它顯示一個semicolan(weired)任何方式。試試這個解決方案以及http://stackoverflow.com/questions/14559060/display-pdf-using-an-ajax-call – mattts

+0

而幾乎忘了嘗試,如果它在Firefox上工作,它很可能會在IE11上工作,我認爲罪魁禍首與您的PDF插件爲IE – mattts

0

添加一個名爲的attachEvent的iframe內..like此功能(在IFRAME jQuery腳本標記之前):

var isIE11 = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/)); 

if (isIE11) { 
    if (typeof window.attachEvent == "undefined" || !window.attachEvent) 
    window.attachEvent = window.addEventListener; 
}