js判断浏览器类型及版本

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

    function CheckBrowser() {  
        ua = navigator.userAgent;  
        ua = ua.toLocaleLowerCase();  
        var browserVersion;  
        if (ua.match(/msie/) != null || ua.match(/trident/) != null) {  
            browserType = "IE";  
            //哈哈,现在可以检测ie11.0了!  
            browserVersion = ua.match(/msie ([\d.]+)/) != null ? ua.match(/msie ([\d.]+)/)[1] : ua.match(/rv:([\d.]+)/)[1];  
        } else if (ua.match(/firefox/) != null) {  
            browserType = "火狐";  
        } else if (ua.match(/opera/) != null) {  
            browserType = "欧朋";  
        } else if (ua.match(/chrome/) != null) {  
            browserType = "谷歌";  
        } else if (ua.match(/safari/) != null) {  
            browserType = "Safari";  
        }  
        var arr = new Array(browserType, browserVersion);  
        return arr;  
    }