码迷,mamicode.com
首页 > 移动开发 > 详细

判断当前设备是移动设备还是PC

时间:2015-03-02 16:40:23      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

var system={
			userAgent:navigator.userAgent.toLowerCase(),
			name:function() {
	            var bIsIpad = this.userAgent.match(/ipad/i) == "ipad";
	            var bIsIphoneOs = this.userAgent.match(/iphone os/i) == "iphone os";
	            var bIsMidp = this.userAgent.match(/midp/i) == "midp";
	            var bIsUc7 = this.userAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
	            var bIsUc = this.userAgent.match(/ucweb/i) == "ucweb";
	            var bIsAndroid = this.userAgent.match(/android/i) == "android";
	            var bIsCE = this.userAgent.match(/windows ce/i) == "windows ce";
	            var bIsWM = this.userAgent.match(/windows mobile/i) == "windows mobile";
	            var bIsPlayBook = this.userAgent.match(/playbook/i) == "playbook";
	            var bIsBlackBerry = this.userAgent.match(/bb10/i) == "bb10";
	            if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM|| bIsPlayBook|| bIsBlackBerry) {
	                return "phone";
	            } else {
	                return "pc";
	            }
	        }
        };

判断当前设备是移动设备还是PC

标签:

原文地址:http://www.cnblogs.com/Frant-Jamie/p/4308906.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!