58

What are all the browsers that support the window.postMessage call now? I am looking for browsers that support it natively, not through an iFrame hack.

Ken Pespisa
  • 21,989
  • 3
  • 55
  • 63
Jamey McElveen
  • 18,135
  • 25
  • 89
  • 129

5 Answers5

79

Can I use cross-document messaging

FF3+, IE8+, Chrome, Safari(5?), Opera10+

Raynos
  • 166,823
  • 56
  • 351
  • 396
11

IE8 does not allow postMessage across windows/tabs

http://blogs.msdn.com/b/ieinternals/archive/2009/09/16/bugs-in-ie8-support-for-html5-postmessage-sessionstorage-and-localstorage.aspx

for more info check here

http://www.openajax.org/member/wiki/Browser_Variation_of_the_Hub_Reference_Implementation_%28Illustrative%29

Keith Beard
  • 1,601
  • 4
  • 18
  • 36
  • Nice for pointing that out! I didn't even know it works across windowws/tabs in other browsers >_> – Raynos May 17 '11 at 20:29
  • any idea if IE9 support postMessage across windows/tabs? – Blowsie Aug 05 '11 at 13:22
  • The postMessage() API now has asynchronous behavior for IE9 mode pages. This article http://blogs.msdn.com/b/ieinternals/archive/2009/09/16/bugs-in-ie8-support-for-html5-postmessage-sessionstorage-and-localstorage.aspx explains the problems still arising in IE9 not sure if it has been corrected yet though. – Keith Beard Aug 05 '11 at 14:36
7

postMessage is supported in IE8+ HOWEVER

  • Remember that IE9 and below require data to be passed in string form and not as an object.
  • IE doesn't like you to call postMessage as soon as page loads (I'm assuming this has to do with the iframe you are posting to needing time to load).
    Use a setTimeout to wait one or two seconds before calling postMessage.
    It took me hours to figure this out and IE wasn't giving me any error message, it was just silently doing nothing until I added the setTimeout.

If you want to start with a demo which actually does work in IE, check out this nifty tutorial by Ilya Kantor

benka
  • 4,732
  • 35
  • 47
  • 58
mags
  • 590
  • 1
  • 8
  • 25
2

For what it's worth recently I ran into some odd webkit browser/versions out in the wild that did NOT support postMessage. I was using IE(8) detection as my means for seeking an alternative. Instead, I probably should have just done some something like this:

if(window.postMessage){
    console.log('Supports post message');
}

Or likely a bit cleaner:

var pm_is_supported = typeof(window.postMessage) == 'function';
benipsen
  • 493
  • 6
  • 12
2

All latest browsers supports that e.g. IE 11, Edge, Firefox 57+, Dafari 11+, iOS Safari 10.2+, Opera mini, Chrome for android, UC Browser etc.

https://caniuse.com/#search=document%20messaging

Jay Shah
  • 3,553
  • 1
  • 27
  • 26