`

浏览器判断

阅读更多
B = (function(ua){
		var b = {
			 msie : /msie/.test(ua) && !/opera/.test(ua),
			opera : /opera/.test(ua),
		   safari : /webkit/.test(ua) && !/chrome/.test(ua),
		  firefox : /firefox/.test(ua),
		   chrome : /chrome/.test(ua)
		};
		var vMark = "";
		for(var i in b){
			if(b[i]){
				vMark = "safari" == i ? "version" : i;
				break;
			}
		}
		b.version = vMark && RegExp("(?:" + vMark + ")[\\/: ]([\\d.]+)").test(ua) ? RegExp.$1 : "0";
		b.ie = b.msie;
		b.ie6 = b.msie && parseInt(b.version, 10) == 6;
		b.ie7 = b.msie && parseInt(b.version, 10) == 7;
		b.ie8 = b.msie && parseInt(b.version, 10) == 8;
		b.ie9 = b.msie && parseInt(b.version, 10) == 9;
		return b;
	})(window.navigator.userAgent.toLowerCase());
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics