我想从 iframe 重定向页面,特别是我想从 iframe 重定向首页。
所以我使用:
top.window.location = 'http://xxx'
它在 mozzila 或 chrome 中工作正常,但在 ie 中我得到:权限被拒绝错误。我发现一些信息表明这是跨域描述问题:
我不知道如何以其他方式做到这一点 - 将父窗口重定向到 iframe 中的某个 url,它位于不同的 url 上(显然)
感谢您的帮助...
最佳答案
有一种方法可以将父框架跨域重定向。其实这是一个诡计。 :-) 如果您有权访问托管父框架的服务器,它将起作用。
在您的框架内,创建一个子框架,该子框架太小而无法看到,并且与父框架位于同一域中。您的小子框架可以更改父文档的位置。
父级:
<iframe src="http://other-domain/doc.html"></iframe>
<小时/>
文档.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>
关于javascript - top.window.location Internet Explorer 权限被拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5732472/