javascript - top.window.location Internet Explorer 权限被拒绝错误

标签 javascript internet-explorer

我想从 iframe 重定向页面,特别是我想从 iframe 重定向首页。

所以我使用:

top.window.location = 'http://xxx'

它在 mozzila 或 chrome 中工作正常,但在 ie 中我得到:权限被拒绝错误。我发现一些信息表明这是跨域描述问题:

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

我不知道如何以其他方式做到这一点 - 将父窗口重定向到 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/

相关文章:

javascript - 条形图列未在 D3/C3 中分组

javascript - 拖动应用phonegap

html - IE 无法正确呈现 <A> 标签

javascript - 无法从表行上的按钮获取引导按钮 ID

javascript - 检查是否选中所有单选按钮

html - 响应式全屏背景。如何让它与 FF 和 IE 一起工作?

css - 不透明度切断文本

javascript - "Interner Explore has stop working"在 IE 11 中出现问题当用户在 html 数字输入上进行选项卡时

java - 如何克服 Internet Explorer 中 selenium web 驱动程序的 ssl 证书错误

JavaScript 对象 : What gets returned from an object constructor