jquery检测浏览器版本

时间:2024-07-26 23:05:02
//检测当前浏览器
function browserType() {
var brow = $.browser;
//console.log(brow);
var bInfo = "";
var type = "";
if (brow.msie) {
type="IE";
bInfo = "Microsoft Internet Explorer " + brow.version;
} else if (brow.mozilla) {
if( ("ActiveXObject" in window) ){
type="IE";
bInfo = "Microsoft Internet Explorer " + brow.version;
}else{
type="MOZILLA";
bInfo = "Mozilla Firefox " + brow.version;
}
} else if (brow.safari) {
type="SAFARI";
bInfo = "Apple Safari " + brow.version;
} else if (brow.opera) {
type="OPERA";
bInfo = "Opera " + brow.version;
} else if (brow.chrome) {
type="CHROME";
bInfo = "chrome " + brow.version;
}else{
type = "IE";
}
//alert(bInfo);
//$("#browser").html(bInfo);
//console.log(("ActiveXObject" in window));
return type;
}