/**
* @param {*} 判断浏览器类型
* @param {*} oneIE 字符串 是否为ie浏览器
*/
myBrowser(oneIE){
var userAgent = navigator.userAgent, //取得浏览器的userAgent字符串
isOpera = userAgent.indexOf("Opera") > -1, //判断是否Opera浏览器
isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera, //判断是否IE11以下浏览器
isIE11 = !!window.ActiveXObject || "ActiveXObject" in window, //判断是否IE11浏览器
isFF = userAgent.indexOf("Firefox") > -1, //判断是否Firefox浏览器
isSafari = userAgent.indexOf("Safari") > -1, //判断是否Safari浏览器
isChrome = userAgent.indexOf("Chrome") > -1; //判断是否Chrome浏览器
if(oneIE && isIE11) {
return "IE";
} else {
if(isIE && !isIE11) {
var IE5 = IE55 = IE6 = IE7 = IE8 = IE9 = IE10 = false,
reIE = new RegExp("MSIE (\\d+\\.\\d+);");
reIE.test(userAgent);
var fIEVersion = parseFloat(RegExp["$1"]),
IE55 = fIEVersion == 5.5,
IE6 = fIEVersion == 6.0,
IE7 = fIEVersion == 7.0,
IE8 = fIEVersion == 8.0,
IE9 = fIEVersion == 9.0,
IE10 = fIEVersion == 10.0;
if(IE55) {
return "IE55";
}
if(IE6) {
return "IE6";
}
if(IE7) {
return "IE7";
}
if(IE8) {
return "IE8";
}
if(IE9) {
return "IE9";
}
if(IE10) {
return "IE10";
}
}
if(isIE11) {
return "IE11";
}
}
//isIE end
if(isFF) {
return "FF";
}
if(isOpera) {
return "Opera";
}
if(isSafari){
return "Safari";
}
if(isChrome) {
return "Chrome";
}
},
网友评论