js获取浏览器类型

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获取浏览器类型

js获取浏览器类型,布布扣,bubuko.com

js获取浏览器类型

上一篇:Node.js中的exports与module.exports的区分


下一篇:如何用JS获取键盘上任意按键的值?兼容FireFox和IE js获取键盘ASCII码?js键盘事件全面控制