What browsers support the window.postMessage call now?
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.
Solution 1:
Can I use cross-document messaging
FF3+, IE8+, Chrome, Safari(5?), Opera10+
Solution 2:
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
Solution 3:
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 asetTimeout
to wait one or two seconds before callingpostMessage
.
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:
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';