Created
February 1, 2014 02:13
-
-
Save shakirullahi/8747042 to your computer and use it in GitHub Desktop.
Detecting IE in javascript
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
//Return IE version or if not IE return false | |
function isIE () { | |
var myNav = navigator.userAgent.toLowerCase(); | |
return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false; | |
} | |
//Example: | |
if (isIE () == 8) { | |
// IE8 code | |
} else { | |
// Other versions IE or not IE | |
} | |
//or | |
if (isIE () < 9) { | |
// is IE version less than 9 | |
} else { | |
// is IE 9 and later or not IE | |
} | |
//or | |
if (isIE()) { | |
// is IE | |
} else { | |
// Other browser | |
} | |
//source http://stackoverflow.com/a/15983064/1442566 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment