js代码判断页面是否手机打开并跳转到相应页面

$(function() {
	iphoneh5();
}); 

//判断手机访问,跳转
function iphoneh5(){
	var ua = navigator.userAgent;
	var ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
	isIphone =!ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
	isAndroid = ua.match(/(Android)\s+([\d.]+)/),
	isMobile = isIphone || isAndroid;
	//判断
	if(isMobile){
		window.location.href="/wap";
	}
}

猜你喜欢

转载自blog.csdn.net/qq_36896749/article/details/88033947