Skip to content

Instantly share code, notes, and snippets.

@djgraham
Created June 1, 2015 16:48
Show Gist options
  • Save djgraham/af878f6bc9a91309848f to your computer and use it in GitHub Desktop.
Save djgraham/af878f6bc9a91309848f to your computer and use it in GitHub Desktop.
torii / popup.js fix for IE11
// IE11 version hack fix...
var ieversion = 0;
var ua = window.navigator.userAgent;
if (ua.indexOf('Trident/') != -1) {
ieversion = ua.substring(ua.indexOf('rv:') + 3);
ieversion = parseInt('' + ieversion, 10);
}
// in IE11 window.attachEvent was removed.
// if IE11 *or* window.attachEvent
if (window.attachEvent || ieversion >= 11) {
postMessageFixed = function postMessageFixed(win, data) {
win.postMessageWithFix(postMessagePrefix+data, postMessageDomain);
};
window.postMessageWithFix = function postMessageWithFix(data, domain) {
setTimeout(function(){
window.postMessage(data, domain);
}, 0);
};
} else {
postMessageFixed = function postMessageFixed(win, data) {
win.postMessage(postMessagePrefix+data, postMessageDomain);
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment