2011-04-20 205 views
0

我想要從iframe重定向頁面,特別是我想重定向iframe中的首頁。top.window.location Internet Explorer權限被拒絕錯誤

所以即時通訊使用:

top.window.location = 'HTTP:// XXX'

其工作在mozzila或鉻罰款,但在IE中我得到:許可被拒絕錯誤。我發現了一些Infor公司,這是跨域scription問題:

http://www.mombu.com/microsoft/microsoft/t-ie-shows-permission-denied-javascript-error-on-toplocationhre-4565452-last.html

II不知道如何做到這一點任何其他方式 - 到父窗口重定向到從一個iframe中的一些網址,至極坐在不同的URL(顯然)

感謝您的幫助...

回答

1

有一種方法來重定向父框架跨域。實際上這是一個騙術。 :-)如果你有權訪問託管父框架的服務器,它將工作。

在您的框架內部,從與父框架相同的域中創建一個太小而無法看到的子框架。您的小孩框架允許更改父文檔的位置。

家長:

<iframe src="http://other-domain/doc.html"></iframe> 

doc.html

All the stuff from the document... 
<iframe width="0" height="0" src="http://original-domain/trick.html"></iframe> 

trick.html 

<script> 
    window.location.replace("http://xxx"); 
</script> 
1

我有同樣的問題,使用:

top.window.location= "http://www.google.com"; 

,我把它改成:

window.parent.location = "http://www.google.com"; 

這解決了這個問題對我來說。

+0

歡迎來到stackoverflow.This帖子可能回答這個問題,但多一點解釋可能會幫助其他程序員理解爲什麼它的工作。 – Daenarys 2015-01-07 13:45:42