Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Check if HTML5 postMessage supports object serialization.
var supportsPostObject = false;
(function(win){
if (window.postMessage) {
var oldIE = false;
var callback = function(e) {
supportsPostObject = typeof(e.data) !== 'string';
oldIE ? win.detachEvent('onmessage', callback) : win.removeEventListener('message', callback, false);
oldIE = callback = null;
};
(oldIE = win.addEventListener === void 0) ? window.attachEvent('onmessage', callback) : win.addEventListener('message', callback, false);
win.postMessage({}, '*');
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment