javascript - IE8 : changing parent. 位置上的跨域 Iframes 问题会强制弹出新窗口。如果在点击事件上,它会按预期工作

标签 javascript internet-explorer cross-domain

我在跨域 iframe 通信工作时遇到了很多麻烦。

它在 Firefox 和 Chrome 上工作,但在 Internet Explorer 上,它只能以某些方式工作:

如果 parent.location = 'new_hash'; 没有包含在 onClick 事件中,它会强制父框架打开一个新的弹出窗口。如果它在 onClick 事件中,则跨域片段标识符技巧起作用。给了什么?

听起来我需要理解 javascript..


编辑评论: parent.location.href 和 parent.location 具有相同的行为。

这似乎是我的特定浏览器 IE 8.0.7600.16385 读取哈希更改作为弹出窗口。我想听听是否还有其他人经历过类似的事情。

在父级中创建弹出窗口:

<script type="text/javascript">
parent.location = 'http://example.com#new_hash';
</script>

在 IE8 中显示“弹出窗口被阻止”对话框。如果我让弹出窗口打开,它们会无限打开弹出窗口。

不在父级中创建弹出窗口:

<a onClick="parent.location='http://example.com#new_hash'">clicky</a>

$(function() { 
 $("mybutton").click( function() { 
   parent.location='http://example.com#new_hash';
});

不在父级中创建弹出窗口。

我的真实例子

我的需要 parent.location=newhash 在它自己的哈希值具有特定值时触发。我基本上有一个:

setInterval(function() { 
 if (location.hash == 'something')
    {
      parent.location='http://example.com#new_hash';
    }  
}, 500);

这是怎么回事?我该如何解决这个问题?为什么它在绑定(bind)到单击事件时有效,但如果语句自行运行则无效?我正在处理的具体示例位于 http://www.grovemade.com/products/test在 v.04

我正在积极地搞乱这里,所以它可能会过时..

在 Firefox 和 Chrome 上,父框架从无哈希修改为#xdm-success,再到#handshake-complete。

在 IE8 上,#xdm-success 强制打开一个新页面。

谢谢!

最佳答案

你不应该设置 parent.location.href 而不是 parent.location 吗?我根本不知道后者有效...

关于javascript - IE8 : changing parent. 位置上的跨域 Iframes 问题会强制弹出新窗口。如果在点击事件上,它会按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3200065/

相关文章:

javascript - solr 正在为我的本地 iis 工作,而不是为托管 iis 工作

javascript - 不能将 document.domain 设置为 herokuapp.com 吗?如何?

javascript - 如何在没有确认页面的情况下提交Google表单数据?

javascript - JavaScript 中的正则表达式

javascript - navigator.cookieEnabled 在本地主机的 IE9 中不起作用

javascript - 如何从 IE8 中的输入获取文件?

java - SecurityError : CSSStyleSheet. cssRules getter:使用 Selenium Firefox 读取 CSS 样式表时不允许访问跨源样式表错误

javascript - 如何在tinyMce中添加自定义 block

javascript - JS onclick 函数不再用于更改链接颜色

html - IE10 : border ignores element's z-index