判断浏览器类型

function detectBrowser(){
 var sUA = navigator.userAgent.toLowerCase();
 var sIE = sUA.indexOf("msie");
 var sOpera = sUA.indexOf("opera");
 var sMoz = sUA.indexOf("gecko");
 if (sOpera != -1) return "opera";
 if (sIE != -1){
  nIeVer = parseFloat(sUA.substr(sIE + 5));
  if (nIeVer >= 6) return "ie6";
  else if (nIeVer >= 5.5) return "ie55";
  else if (nIeVer >= 5 ) return "ie5";
 }
 if (sMoz != -1) return "moz";
 return "other";
}

function isIE() {
 return detectBrowser().indexOf("ie")>-1;
}

你可能感兴趣的:(浏览器类型判断)