jquery 1.9 1.8 判断 浏览器(IE11,IE8,IE7,IE6)版本

时间:2023-03-10 07:16:48
jquery 1.9 1.8 判断 浏览器(IE11,IE8,IE7,IE6)版本

1.9以后很我方法删除了,所有和之前版本判断浏览器版本有所差记录一下

1.9

----------------------------------------------------------------------------------------------

if (/msie/.test(navigator.userAgent.toLowerCase())) {
//IE6
if ('undefined' == typeof (document.body.style.maxHeight)) {
$('#toolInfo').show();
} else {
//IE6-8
//if (!$.support.leadingWhitespace) {
// $('#toolInfo').show();
//}
var ua1 = navigator.userAgent.toLowerCase();
if (ua1.match(/msie/) != null || ua1.match(/trident/) != null) {
//浏览器类型
var browserType1 = "IE";
//浏览器版本
var browserVersion1 = ua1.match(/msie ([\d.]+)/) != null ? ua1.match(/msie ([\d.]+)/)[1] : ua1.match(/rv:([\d.]+)/)[1];
if (browserVersion1.indexOf('7') > -1) {
$('#toolInfo').show();
}
}
}
}
else if (/firefox/.test(navigator.userAgent.toLowerCase())||
/webkit/.test(navigator.userAgent.toLowerCase())||
/opera/.test(navigator.userAgent.toLowerCase())) {
//(当是火狐的时候)不显示(因为IE11采用的是火狐的内核)
$('#toolInfo').show();
}
else {
//IE11
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
//浏览器类型
var browserType = "IE";
//浏览器版本
var browserVersion = ua.match(/msie ([\d.]+)/) != null ? ua.match(/msie ([\d.]+)/)[1] : ua.match(/rv:([\d.]+)/)[1]; } else {
$('#toolInfo').show();
}
}

1.8.3

------------------------------------------------------------------------------------------------------------------------------

//当前如果不是IE浏览器或IE版本低于IE8的都要给出系统不支持的提示,并且给出下载安装包
if ($.browser.msie) {
if (parseFloat($.browser.version) < 8) {
$('#toolInfo').show();
}
}
else if ($.browser.mozilla) {
//(当是火狐的时候)不显示(因为IE11采用的是火狐的内核)
}
else {
$('#toolInfo').show();
}

代码有点乱,