js获取浏览器类型

function add(){
            var userAgent = navigator.userAgent,   
            rMsie = /(msie\s|trident.*rv:)([\w.]+)/,   
            rFirefox = /(firefox)\/([\w.]+)/,   
            rOpera = /(opera).+version\/([\w.]+)/,   
            rChrome = /(chrome)\/([\w.]+)/,   
            rSafari = /version\/([\w.]+).*(safari)/;  
            var browser;  
            var version;  
            var ua = userAgent.toLowerCase();  
            var stu_name;
            function uaMatch(ua) {  
                var match = rMsie.exec(ua);  
                if (match != null) {  
                    alert("IE");
                    stu_name = $("#stu_name").text().split("\n"); 
                    alert(stu_name);
                }  
                var match = rFirefox.exec(ua);  
                if (match != null) {  
                    alert("rFirefox");
                    stu_name = $("#stu_name").val().split("\n"); 
                    alert(stu_name);
                }  
                var match = rOpera.exec(ua);  
                if (match != null) {  
                    alert("rOpera");
                    stu_name = $("#stu_name").val().split("\n"); 
                    alert(stu_name);
                }  
                var match = rChrome.exec(ua);  
                if (match != null) {  
                    alert("rChrome");
                    stu_name = $("#stu_name").val().split("\n"); 
                    alert(stu_name);
                }  
                var match = rSafari.exec(ua);
                if (match != null) {
                    alert("rSafari");
                    stu_name = $("#stu_name").val().split("\n"); 
                    alert(stu_name);
                }  
                if (match != null) {
                    alert("null");
                    stu_name = $("#stu_name").val().split("\n"); 
                    alert(stu_name);
                }  
            }  
            var browserMatch = uaMatch(userAgent.toLowerCase());  
}

js获取浏览器类型,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。