ie,firefox,opera,chrome,safari js 判断五大主流浏览器

用js 判断五大主流浏览器类型

function getBrowser() {
	var ua = window.navigator.userAgent;
	var isIE = window.ActiveXObject != undefined && ua.indexOf("MSIE") != -1;
	var isFirefox = ua.indexOf("Firefox") != -1;
	var isOpera = window.opr != undefined;
	var isChrome = ua.indexOf("Chrome") && window.chrome;
	var isSafari = ua.indexOf("Safari") != -1 && ua.indexOf("Version") != -1;
	if (isIE) {
		return "IE";
	} else if (isFirefox) {
		return "Firefox";
	} else if (isOpera) {
		return "Opera";
	} else if (isChrome) {
		return "Chrome";
	} else if (isSafari) {
		return "Safari";
	} else {
		return "Unkown";
	}
}
alert(getBrowser());


 
  

你可能感兴趣的:(ie,firefox,opera,chrome,safari js 判断五大主流浏览器)