-
-
Save cristobal/1222914 to your computer and use it in GitHub Desktop.
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
/** | |
* Test for IE | |
* - http://blogs.msdn.com/giorgio/archive/2009/04/14/how-to-detect-ie8-using-javascript-client-side.aspx | |
* - http://blogs.msdn.com/mikeormond/archive/2008/09/25/ie-8-compatibility-meta-tags-http-headers-user-agent-strings-etc-etc.aspx | |
* - http://msdn.microsoft.com/en-gb/library/cc817572.aspx | |
* - http://stackoverflow.com/questions/5825385/javascript-can-i-detect-ie9-if-its-in-ie7-or-ie8-compatibility-mode | |
*/ | |
if(window.ActiveXObject){ | |
var rv = -1; | |
var ua = navigator.userAgent; | |
var re = new RegExp("Trident\/([0-9]{1,}[\.0-9]{0,})"); | |
if (re.test(ua)) { | |
rv = parseFloat(RegExp.$1); | |
} | |
var msie9 = (rv == 5) || ("performance" in window); | |
var msie8 = (rv == 4) && !msie9; | |
var msie7 = window.XMLHttpRequest && !(msie8 || msie9); | |
// var msie6 = (!!(window.attachEvent && navigator.userAgent.indexOf('Opera') === -1)) && /MSIE 6/i.test(navigator.userAgent); | |
// var msie6 = !(msie7 || msie8 || msie9); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment