Which browsers support the window.postMessage call?

What are browsers now supporting the window.postMessage call? I am looking for browsers that support it natively, and not due to iFrame hacking.

+52
javascript cross-browser
May 17 '11 at 20:03
source share
4 answers

Can I use messaging between documents

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

+75
May 17 '11 at 20:08
source share

postMessage is supported in IE8 + HOWEVER

  • Remember that IE9 and below require data transfer in string form, and not as an object.
  • IE doesn’t want you to call postMessage as soon as the page loads (I assume this is due to what you send when time needs to be loaded).
    Use setTimeout to wait one or two seconds before calling postMessage .
    It took me several hours to figure this out, and IE did not give me any error message, it just didn’t do anything until I added setTimeout.

If you want to start with a demo that really works in IE, check out this great tutorial Ilya Kantor

+7
Sep 11 '14 at 9:07
source share

Recently, I came across some odd browsers / webkit versions in the wild that did NOT support postMessage. I used IE (8) discovery as an alternative search tool. Instead, I probably should have done something like this:

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

Or maybe a little cleaner:

 var pm_is_supported = typeof(window.postMessage) == 'function'; 
+2
Mar 26 '14 at 20:01
source share



All Articles