Skip to content

Instantly share code, notes, and snippets.

@shakirullahi
Created February 1, 2014 02:13
Show Gist options
  • Save shakirullahi/8747042 to your computer and use it in GitHub Desktop.
Save shakirullahi/8747042 to your computer and use it in GitHub Desktop.
Detecting IE in javascript
//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