如何用JavaScript判断是否为IE浏览器?
程序员文章站
2022-04-05 08:07:37
...
isIE() {
var ua = window.navigator.userAgent;
var msie = ua.indexOf("MSIE ");
if (msie > 0) {
// IE 10 or older => return version number
return true;
}
var trident = ua.indexOf("Trident/");
if (trident > 0) {
// IE 11 => return version number
return true;
}
var edge = ua.indexOf("Edge/");
if (edge > 0) {
// Edge (IE 12+) => return version number
return true;
}
// other browser
return false;
},