根据判断移动端还是pc端自动跳转页面

方法-:

 

var browser = {
versions : function() {
var u = navigator.userAgent, app = navigator.appVersion;
return {//移动终端浏览器版本信息                                                              
mobile : (!!u.match(/AppleWebKit.*Mobile/) || !!u.match(/Windows Phone/) || !!u.match(/Android/) || !!u.match(/MQQBrowser/)) && !u.match(/iPad/)//是否为移动终端                                 
};
}()
}
if(browser.versions.mobile){
 window.location.href="<a href="http://www.xxx.com/wap.html";" target="_blank">http://www.xxx.com/wap.html";</a>
}



 

 


方法二:

 

<script type="text/javascript">
function goPAGE() {
	if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
		window.location.href="wap/";
	}/*else {
		window.location.href="../";	
	}*/
}
goPAGE();
</script>



 

posted @ 2017-03-30 15:57  昌子玩前端  阅读(17)  评论(0)    收藏  举报  来源