本帖最后由 wushaominkk 于 2018-6-22 00:59 编辑
整理了一下移动端系统及浏览器
注:js会先判断移动端系统再判断浏览器,如果判断的系统和浏览器同级,那么他只会读取判断得到系统的信息而不是浏览器的信息;
[JavaScript] 纯文本查看 复制代码 $(function(){
toMobile();
})
function toMobile(){
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; //ipad
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; //苹果系统
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc = sUserAgent.match(/ucbrowser/i) == "ucbrowser"; //UC浏览器
var bIsAndroid = sUserAgent.match(/android/i) == "android"; //安卓系统
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; //微软掌上电脑
var bIsQQ = sUserAgent.match(/qq/i) == "qq";//内置qq及QQ浏览器
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
var bIsIE = sUserAgent.match(/iemobile/i) == "iemobile";
var bIsWx = sUserAgent.match(/MicroMessenger/i)=="micromessenger"//微信内置浏览器
if (bIsIpad || bIsMidp || bIsAndroid || bIsCE || bIsWM||bIsIE) {
alert(sUserAgent);
}else if (bIsIphoneOs) {
if (bIsUc) {
alert("uc");
}else if (bIsQQ) {
alert("qq");
}else if (bIsWx) {
alert("wx");
}
}else{
}
} |