-
-
Save peteboere/814550 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ---------------------------------------------------------- | |
// A short snippet for detecting versions of IE: | |
// Uses a combination of object detection and user-agent | |
// sniffing. | |
// ---------------------------------------------------------- | |
// If you're not in IE then: | |
// ie === NaN // falsy | |
// If you're in IE then you can determine which version: | |
// ie === 7; // IE7 | |
// Thus, to detect IE: | |
// if (ie) {} | |
// And to detect the version: | |
// ie === 6 // IE6 | |
// ie > 7 // IE8, IE9 ... | |
// ie < 9 // Anything less than IE9 | |
// ---------------------------------------------------------- | |
var ie = ('ActiveXObject' in window && +(/\s(?:MSIE\s|rv\:)(\d+)/.exec(navigator.userAgent)[1])) || NaN |
This file contains hidden or 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
// The same thing but for IE Mobile instead. | |
var ieMobile = ( !! window.ActiveXObject && +( /IEMobile\/(\d+\.?(\d+)?)/.exec( navigator.userAgent )[1] ) ) || NaN; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Testing for 'mise' in the userAgent string will not work for version 11 as Microsoft has remove that string. The closest thing you might use is 'trident'. You also cannot use 'IEMobile' to detect Tablet mobile devices as they use a version of Windows for desktop. You should additionally be careful to properly detect both the RT and full desktop versions.