JS判断是否是手机

本文由清尘发表于2018-01-11 10:25最后修改于2018-09-17属于javascript分类
function mobiCheck(){
	var ua = navigator.userAgent,
	android = ua.match(/(Android);?[\s\/]+([\d.]+)?/),
	ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
	ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/),
	iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);

	if(android || iphone || ipod){
		var goUrl = 'https://blog.ipsfan.com/mytools/jx3qx/m/#/changGe';
		window.location.href = goUrl;
	}
}