Skip to content

Instantly share code, notes, and snippets.

@bjankord
Created December 8, 2012 13:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bjankord/4240280 to your computer and use it in GitHub Desktop.
Save bjankord/4240280 to your computer and use it in GitHub Desktop.
JS IE Detection with conditional comments
var ieCheck = document.createElement('div');
ieCheck.innerHTML = '<!--[if lt IE 7]>IE6<![endif]--><!--[if IE 7]>IE7<![endif]--><!--[if IE 8]>IE8<![endif]--><!--[if IE 9]>IE9<![endif]-->';
if (ieCheck.innerHTML === 'IE6') {
alert('IE6 or lower');
} else if (ieCheck.innerHTML === 'IE7') {
alert('IE7');
} else if (ieCheck.innerHTML === 'IE8') {
alert('IE8');
} else if (ieCheck.innerHTML === 'IE9') {
alert('IE9');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment