js 判断浏览器

function isBrowser() {
	var userAgent = navigator.userAgent;
	//微信内置浏览器
	if(ua.match(/MicroMessenger\/[0-9]/i)) {
		return "MicroMessenger";
	}
	//QQ内置浏览器
	else if(ua.match(/QQ\/[0-9]/i)) {
		return "QQ";
	}
	//Chrome
	else if(userAgent.match(/Chrome/i) == 'Chrome') {
		return "Chrome";
	}
	//Opera
	else if(userAgent.match(/Opera/i) == 'Opera') {
		return "Opera";
	}
	//Firefox
	else if(userAgent.match(/Firefox/i) == 'Firefox') {
		return "Firefox";
	}
	//Safari
	else if(userAgent.match(/Safari/i) == 'Safari') {
		return "Safari";
	}
	//IE
	else if(!!window.ActiveXObject || "ActiveXObject" in window) {
		return "IE";
	}
	else {
		return "未定义:"+userAgent;
	}
}

js 判断浏览器_第1张图片

你可能感兴趣的:(JavaScript,-,Jquery)