做H5页面的时候,经常会用到判断手机是什么系统,根据系统的型号,实现不同的效果,那么如何判断显示页面的手机型号呢?

(function(){
	var isMobile={
		Android:function(){
			return navigator.userAgent.match(/Android/i)?true:false;
		},
		Ios:function(){
			return navigator.userAgent.match(/iPhone|iPad|iPod/i)?true:false;
		},
		BlackBrrey:function(){
			return navigator.userAgent.match(/BlackBrrey/i)?true:false;
		},
		Windows:function(){
			return navigator.userAgent.match(/IEMobile/i)?true:false;
		},
		any:function(){
			return (isMobile.Android() || isMobile.Ios() || isMobile.BlackBrrey || isMobile.Windows());
		}
	};
	if(isMobile.Ios()){
		//执行手机系统是ios的代码
	}else{
		//执行其余手机系统的代码
	}
})(window);

  

posted on 2017-06-16 16:35  太阳花0525  阅读(351)  评论(0编辑  收藏  举报