js判断浏览器

if (navigator.userAgent.indexOf("Opera") != -1) {
// document.write('您的浏览器是Opera吧?');
window.location.href = '/LoginMore.aspx';
}
// 包含「MSIE」文字列
else if (navigator.userAgent.indexOf("MSIE") != -1) {
// document.write('您的浏览器是Internet Explorer吧?');
window.location.href = '/Login.aspx';
}
else if (navigator.userAgent.indexOf('Trident') > -1 && navigator.userAgent.indexOf('rv:11') > -1) {
//alert('IE11');
window.location.href = '/Login.aspx';
} else if (navigator.userAgent.indexOf('MSIE') > -1 && navigator.userAgent.indexOf('Trident') > -1) {

// alert('IE8-10');
window.location.href = '/Login.aspx';
} else if (navigator.userAgent.indexOf('MSIE') > -1) {
//browser_name='IE(6-7)';
// alert(6 - 7);
window.location.href = '/Login.aspx';
}
// 包含「Firefox」文字列
else if (navigator.userAgent.indexOf("Firefox") != -1) {
// document.write('您的浏览器时Firefox吧?');
window.location.href = '/LoginMore.aspx';
}
// 包含「Netscape」文字列
else if (navigator.userAgent.indexOf("Netscape") != -1) {
// document.write('您的浏览器时Netscape吧?');
window.location.href = '/LoginMore.aspx';
}
// 包含「Safari」文字列
else if (navigator.userAgent.indexOf("Safari") != -1) {
// document.write('您的浏览器时Safari 吧?');
window.location.href = '/LoginMore.aspx';
}
else {
// document.write('无法识别的浏览器。');
window.location.href = '/LoginMore.aspx';
}

原文地址:https://www.cnblogs.com/zhangweixin/p/4843706.html