判断浏览器类型

function GetBrowserType(){

  var userAgent = navigator.userAgent;

  if(userAgent.indexOf("MSIE")>0){

    var b_version = navigator.appVersion;

    var version = b_version.split(";");

    var trim_version = version[1].replace(/[]/g, "");

    if (trim_Version == "MSIE6.0") {
      return "IE6";
    } else if(trim_Version == "MSIE7.0") {
      return "IE7";
    } else if (trim_Version == "MSIE8.0") {
      return "IE8";
    } else if (trim_Version == "MSIE9.0") {
      return "IE9";
    }

  }

  if (isFirefox = navigator.userAgent.indexOf("Firefox") > 0) {
    return "Firefox";
  }
  if (isSafari = navigator.userAgent.indexOf("Safari") > 0) {
    return "Safari"; //google
  }
  if (isCamino = navigator.userAgent.indexOf("Camino") > 0) {
    return "Camino";
  }
  if (isMozilla = navigator.userAgent.indexOf("Gecko/") > 0) {
    return "Gecko";
  }

}

原文地址:https://www.cnblogs.com/fiona-zhong/p/10595887.html