IE8 / 9 window.postMessage无法正常工作,但为什么? [英] IE8/9 window.postMessage not working, but why?

查看:588
本文介绍了IE8 / 9 window.postMessage无法正常工作,但为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

postMessage是一个HTML5 API,它适用于所有主流浏览器,包括IE8 / 9。我想要做的是从页面创建一个弹出窗口,并能够使用postMessage与弹出窗口对话。这适用于IE8 / 9以外的所有浏览器。失望!

The "postMessage" is an HTML5 API, it is available in all major browsers including IE8/9. What I am trying to do is to create a popup window from a page, and be able to talk to the popup window using "postMessage". This works in every browser except IE8/9. Disappointed!

看起来IE8 / 9只允许iframe之间的通信,但不允许在两个窗口之间进行通信,甚至窗口都在同一层次结构中。

It looks like IE8/9 only allows the communication between iframes, but not between two windows, even the windows are within the same hierarchy.

推荐答案

.postMessage 方法工作,你只需要从IE8及以上了解 的工作原理。不幸的是,对于IE8和IE9,它不会做你想要的(虽然它在IE10中)。虽然您可以在IE8 / 9中的帧之间发送消息,但您无法将消息发送到单独的窗口。

The .postMessage method works, you just need to understand how it works from IE8 and up. Unfortunately, for IE8 and IE9 it will not do what you're seeking (though it does in IE10). While you can send messages between frames in IE8/9, you cannot send messages to a separate window.

有一种解决方法适用于 some 实例。 Martin Beeby在他关于这个问题的博客文章的最后一段中讨论了这个问题: PostMessage Popups和IE

There is a work-around that works in some instances. Martin Beeby discusses it in the last paragraph of his blog post on the issue: PostMessage Popups and IE.

有关此内容以及其他一些注意事项的更多信息,请参阅Eric Lawrence的在MSDN上发帖

For more on this, and a few other caveats, see Eric Lawrence's post on MSDN.

这篇关于IE8 / 9 window.postMessage无法正常工作,但为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆