function getBrowser() {
var ua = navigator.userAgent.toLocaleLowerCase();
var Browser = null;
if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
Browser = "IE";
browserVersion =
ua.match(/msie ([\d.]+)/) != null
? ua.match(/msie ([\d.]+)/)[1]
: ua.match(/rv:([\d.]+)/)[1];
return "IE";
} else if (ua.match(/firefox/) != null) {
Browser = "火狐";
return "FF";
} else if (ua.match(/ubrowser/) != null) {
Browser = "UC";
return "UC";
} else if (ua.match(/opera/) != null) {
Browser = "欧朋";
return "OP";
} else if (ua.match(/bidubrowser/) != null) {
Browser = "百度";
return "baidu";
} else if (ua.match(/metasr/) != null) {
Browser = "搜狗";
return "SG";
} else if (
ua.match(/tencenttraveler/) != null ||
ua.match(/qqbrowse/) != null
) {
Browser = "QQ";
return "QQ";
} else if (ua.match(/maxthon/) != null) {
Browser = "遨游";
return "AY";
} else if (ua.match(/chrome/) != null) {
var is360 = _mime("type", "application/vnd.chromium.remoting-viewer");
function _mime(option, value) {
var mimeTypes = navigator.mimeTypes;
for (var mt in mimeTypes) {
if (mimeTypes[mt][option] == value) {
return true;
}
}
return false;
}
if (is360) {
Browser = "360";
return "360";
} else {
return "Chrome";
}
} else if (ua.match(/safari/) != null) {
Browser = "Safari";
}
}
function btn() {
let Browser = getBrowser()
if ('FF' == Browser) {
console.log('我是火狐')
} else if ('IE' == Browser) {
console.log('我是IE')
} else if ('UC' == Browser) {
console.log('我是UC')
} else if ('op' == Browser) {
console.log('我是欧朋')
} else if ('baidu' == Browser) {
console.log('我是百度')
} else if ('SG' == Browser) {
console.log('我是搜狗')
} else if ('QQ' == Browser) {
console.log('我是QQ')
} else if ('AY' == Browser) {
console.log('我是遨游')
} else if ('360' == Browser) {
console.log('我是360')
} else if ('Chrome' == Browser) {
console.log('我是谷歌')
}
}