2011-04-20 302 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