我想从iframe重定向页面,特别是我想从iframe重定向首页。
所以我使用:
top.window.location = 'http://xxx‘
它在mozzila或chrome中工作得很好,但在ie中我得到了:权限被拒绝的错误。我发现了一些信息,这是跨域脚本问题:
我不知道该怎么做--将父窗口从iframe重定向到某个url,这显然是位于不同的url上的。
谢谢你的帮助。
发布于 2011-08-02 08:10:16
有一种方法可以跨域重定向父框架。实际上,这是个骗局。:-)如果您有权访问托管父框架的服务器,它将会工作。
在框架内,从与父框架相同的域创建一个太小而看不见的子框架。允许您的小子框架更改父文档的位置。
父级:
<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>
发布于 2015-01-07 13:25:41
我也遇到了同样的问题,使用:
top.window.location= "http://www.google.com";
我把它改成了:
window.parent.location = "http://www.google.com";
为我解决了这个问题。
https://stackoverflow.com/questions/5732472
复制相似问题