What browsers support the window.postMessage call now?

JavascriptCross Browser

Javascript Problem Overview


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.

Javascript Solutions


Solution 1 - Javascript

Can I use cross-document messaging

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

Solution 2 - Javascript

Solution 3 - Javascript

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

Solution 4 - Javascript

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';

Solution 5 - Javascript

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJamey McElveenView Question on Stackoverflow
Solution 1 - JavascriptRaynosView Answer on Stackoverflow
Solution 2 - JavascriptKeith BeardView Answer on Stackoverflow
Solution 3 - JavascriptmagsView Answer on Stackoverflow
Solution 4 - JavascriptbenipsenView Answer on Stackoverflow
Solution 5 - JavascriptJay ShahView Answer on Stackoverflow