1var ua = window.navigator.userAgent;
2var msie = ua.indexOf('MSIE ');
3if (msie > 0) {
4 // IE 10 or older => return version number
5 return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
6}
7
8var ua = window.navigator.userAgent;
9var trident = ua.indexOf('Trident/');
10if (trident > 0) {
11 // IE 11 => return version number
12 var rv = ua.indexOf('rv:');
13 return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
14}
15
16var ua = window.navigator.userAgent;
17var edge = ua.indexOf('Edge/');
18if (edge > 0) {
19 // Edge (IE 12+) => return version number
20 return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
21}