js判断浏览器

 
function CheckBrowser(){

    var cb = "Unknown";

    if(window.ActiveXObject){

        cb = "IE";

    }else if(navigator.userAgent.toLowerCase().indexOf("firefox") != -1){

        cb = "Firefox";

    }else if((typeof document.implementation != "undefined") && (typeof document.implementation.createDocument != "undefined") && (typeof HTMLDocument != "undefined")){

        cb = "Mozilla";

    }else if(navigator.userAgent.toLowerCase().indexOf("opera") != -1){

        cb = "Opera";

    }

    return cb;

}

你可能感兴趣的:(浏览器,function,Opera,IE,firefox,mozilla)