Code Snippet
Test for Internet Explorer in JavaScript
var isMSIE = /*@cc_on!@*/0;
if (isMSIE) {
// do IE-specific things
} else {
// do non IE-specific things
}var isMSIE = /*@cc_on!@*/0;
if (isMSIE) {
// do IE-specific things
} else {
// do non IE-specific things
}
if (-[1,]) {
// do non IE-specific things
} else {
// do IE-specific things
}
doesn’t work ie 9
If you need to know if an IE browser is used purely for the sake of implementing IE-specific css rules, you can simply put the following code at the top of your html file. Basically it places an tag with a css class for ie 6 through 9.
This way u dont need any javascript to use IE-specific css code.