js判断浏览器类型及版本

下面是编程之家 jb51.cc 通过网络收集整理的代码片段。

编程之家小编现在分享给大家,也给大家做个参考。

    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;  
    }  

以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...