IE8 / 9 window.postMessage无法正常工作,但为什么?

编程入门 行业动态 更新时间:2024-10-22 14:33:26
本文介绍了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无法正常工作,但为什么?

本文发布于:2023-11-05 07:56:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1560293.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   但为   工作   window   postMessage

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!