码迷,mamicode.com
首页 > Web开发 > 详细

js判断浏览器类型及版本

时间:2015-07-03 19:17:14      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:js   jquery   

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;
}
<pre name="code" class="javascript">欢迎加入软件交流群:398918539

    
        

版权声明:本文为博主原创文章,未经博主允许不得转载。

js判断浏览器类型及版本

标签:js   jquery   

原文地址:http://blog.csdn.net/u010407050/article/details/46744229

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!