Created
June 1, 2015 16:48
-
-
Save djgraham/af878f6bc9a91309848f to your computer and use it in GitHub Desktop.
torii / popup.js fix for IE11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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