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

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";
	            }
	        }
        };
posted @ 2015-03-02 15:33  Jamie Zheng  阅读(381)  评论(1编辑  收藏  举报