Last active
August 29, 2015 13:55
-
-
Save jonathanread/8711501 to your computer and use it in GitHub Desktop.
Suck it IE 11
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
//Pass "IE=9", "IE=10" etc. | |
function DetectIE11AndRenderUACompat(mode) | |
{ | |
var rv = -1; | |
if (navigator.appName == 'Microsoft Internet Explorer') { | |
var ua = navigator.userAgent; | |
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); | |
if (re.exec(ua) != null) | |
rv = parseFloat(RegExp.$1); | |
} | |
else if (navigator.appName == 'Netscape') { | |
var ua = navigator.userAgent; | |
var re = new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})"); | |
if (re.exec(ua) != null) | |
rv = parseFloat(RegExp.$1); | |
} | |
if (rv == 11) { | |
var renderMetaTag = document.createElement('meta'); | |
renderMetaTag.httpEquiv = "X-UA-Compatible"; | |
renderMetaTag.content = mode; | |
document.getElementsByTagName('head')[0].appendChild(renderMetaTag); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment