1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

IE8でwindow.postMessage()して返ってくるEventはMessageEventではない

Last updated at Posted at 2014-05-26

例えばiframeに対してpostMessage()でなにか通信をしたい時、

parent
var iframe = $('iframe');
iframe.contentWindow.postMessage('moge', '*');

この時、iframe側で受け取ったEventはMessageEventという型になっているんだけど、
IE8ではただのEvent型になっているので注意が必要。

そもそもMessageEventというオブジェクト自体が定義されていないのでevt instanceof MessageEventみたいなことはできない。

iframe
window.addEventListener('message', function(evt) {
   console.log(evt instanceof MessageEvent)); // IE8で死ぬ。死は避けられない。人はいつか死ぬ。
});
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?