//判断当前浏览类型
function browerTips() {
var browserFlag = '';
var IeVersion = '';
var browserVersion = '';
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
console.log(userAgent);
var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
var isEdge = userAgent.indexOf("Edge") > 0;
var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
var isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
var isChrome = userAgent.indexOf("Chrome") > -1 && userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Edge") == -1; //判断Chrome浏览器
var isUcBrowser = userAgent.indexOf("UBrowser") > -1; // 判断UC浏览器
var IeNoSupportFlag = true;
var browserTypeFlag = "";
var flag = true;
var support_flag = false;
var OsObject = window.navigator.userAgent;
if (isIE) {
var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
reIE.test(userAgent);
var fIEVersion = parseFloat(RegExp["$1"]);
if (fIEVersion == 5) {
IeVersion = "IE5";
IeNoSupportFlag = false;
}
else if (fIEVersion == 6) {
IeVersion = "IE6";
IeNoSupportFlag = false;
}
else if (fIEVersion == 7) {
IeVersion = "IE7";
IeNoSupportFlag = false;
}
else if (fIEVersion == 8) {
IeVersion = "IE8";
IeNoSupportFlag = false;
}
else if (fIEVersion == 9)
{ IeVersion = "IE9"; }
else if (fIEVersion == 10)
{ IeVersion = "IE10"; }
else if (fIEVersion == 11)
{ IeVersion = "IE11"; }
else
{ IeVersion = "0" }//IE版本过低
// browserVersion = IeVersion;
browserTypeFlag = IeVersion;
}
if (isFF) {
browserTypeFlag = "Firefox";
}
if (isOpera) {
browserTypeFlag = "Opera";
}
if (isSafari) {
browserTypeFlag = "Safari";
flag = false;
}
if (isChrome) {
browserTypeFlag = "Chrome";
flag = false;
}
if (isEdge) {
browserTypeFlag = "Edge";
flag = false;
}
if (isUcBrowser) {
browserTypeFlag = "UC浏览器";
}
if (!(isFF || isOpera || isSafari || isChrome || isEdge || isUcBrowser)) {
browserTypeFlag = "未知浏览器";
}
if (!!window.ActiveXObject || "ActiveXObject" in window) {
if (OsObject.indexOf("MSIE") > 0) {
var version = OsObject.match(/MSIE \d+/i);
var versionNum = version[0].match(/\d+/i);
if (parseInt(versionNum) > 9) {
flag = false;
}
} else if (OsObject.toLowerCase().indexOf("trident") > -1 && OsObject.indexOf("rv") > -1) {
flag = false;
}
}
if (!flag) {
support_flag = filterNavigatorNoSupport(OsObject);
}
if (!flag && !support_flag) {
//浏览器支持,跳转到平台的url.
return;
} else {
window.location.href = "jianrong.html";
return;
}
}
function filterNavigatorNoSupport(OsObject) {
//搜狗 MetaSr 遨游 Maxthon QQ QQBrowser 猎豹 LBBROWSER 百度 BIDUBrowser 淘宝 TaoBrowser UC UBrowser
if (OsObject.indexOf("MetaSr") > 0 || OsObject.indexOf("UBrowser") > 0 || OsObject.indexOf("Maxthon") > 0 || OsObject.indexOf("QQBrowser") > 0 || OsObject.indexOf("LBBROWSER") > 0 || OsObject.indexOf("BIDUBrowser") > 0 || OsObject.indexOf("TaoBrowser") > 0) {
return true;
}
return false;
}
browerTips();