JS 判断当前浏览器客户端是否为手机

发表于 2021-12-26 11:10:22   |   下载附件   |   字体:
是否为手机访问userAgentnavigator
// 是否是手机端
var iswap = function(){
	if (/(Mobile|Android|WAP|NetFront|JAVA|OperasMini|UCWEB|WindowssCE|Symbian|Series|webOS|SonyEricsson|Sony|BlackBerry|Cellphone|dopod|Nokia|samsung|PalmSource|Xphone|Xda|Smartphone|PIEPlus|MEIZU|MIDP|CLDC)/i.test(navigator.userAgent)) {
		return "android";
	}else if(/(iPhone)/i.test(navigator.userAgent)) {
		return "iphone";
	}else{
		if(/(mozilla|chrome|safari|opera|m3gate|winwap|openwave)/i.test(navigator.userAgent)) {
			return false;
		}else{
			if(getUrlPre('mobile')) {
				return true;
			}else{
				return false;
			}
		}
	}
}