Share: Detect IE and its version

This post will tell you how detect IE and its version. Refer: http://stackoverflow.com/questions/10964966/detect-ie-version-in-javascript

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!DOCTYPE html>
<html lang="">

<head>
<meta charset="UTF-8">
<title>IE Tester</title>
</head>

<body>
<script>
function isIE() {
var myNav = navigator.userAgent.toLowerCase();
return (myNav.indexOf('msie') != -1) ? parseInt(myNav.split('msie')[1]) : false;
}
if (isIE() && isIE() <= 9) {
// is IE version less than 9
console.log("small");
} else {
// is IE 9 and later or not IE
console.log("large");
}
</script>
</body>

</html>

ScreenShots:

IE 10 IE 9 IE 7