2016-03-18 46 views

回答

0

您可以通過選項「X-Frame-Options」從網址獲取標題。
這將返回DENYSAMEORIGINALLOW-FROM

0

如果您嘗試從另一個域加載您的iframe中的url,您可以嘗試這樣的事情。

//get the iframe object 
var iframe = document.getElementById('Frame'); 


var iframeDocument; 


    try{ 

     //cross browser solution to get the iframe document 
     //of the iframe 
     iframeDocument = iframe.contentDocument || iframe.contentWindow.document; 

    } 
    catch(error){ 

     alert(error); 

    } 
+0

即使iframe正確加載,我得到一個錯誤 – nootb

+0

@nootb你得到什麼錯誤?它爲我工作。什麼是你的框架的ID?我爲我的示例使用了框架,但您將不得不更改document.getElementById()參數以匹配您的iframe的ID。 –

+0

@noob我道歉,不知何故,當我選擇iframeDocument = iframe.contentDocument || iframe.contentWindow.document;部分來複制並粘貼到解決方案中,它切換了文檔部分中拼湊的一些字母。我糾正了語法錯誤。當你有機會時再試一次,讓我知道它是否適合你。 –

相關問題