首页 > Web开发 > 详细

jquery 1.9 1.8 判断 浏览器(IE11,IE8,IE7,IE6)版本

时间:2016-08-01 17:29:39      阅读:581      评论:0      收藏:0      [点我收藏+]

1.9以后很我方法删除了,所有和之前版本判断浏览器版本有所差记录一下

1.9

----------------------------------------------------------------------------------------------

if (/msie/.test(navigator.userAgent.toLowerCase())) {
            //IE6
            if (‘undefined‘ == typeof (document.body.style.maxHeight)) {
                $(‘#toolInfo‘).show();
            } else {
                //IE6-8
                //if (!$.support.leadingWhitespace) {
                //    $(‘#toolInfo‘).show();
                //}
                var ua1 = navigator.userAgent.toLowerCase();
                if (ua1.match(/msie/) != null || ua1.match(/trident/) != null) {
                    //浏览器类型  
                    var browserType1 = "IE";
                    //浏览器版本  
                    var browserVersion1 = ua1.match(/msie ([\d.]+)/) != null ? ua1.match(/msie ([\d.]+)/)[1] : ua1.match(/rv:([\d.]+)/)[1];
                    if (browserVersion1.indexOf(‘7‘) > -1) {
                        $(‘#toolInfo‘).show();
                    }
                }
            }
        }
        else if (/firefox/.test(navigator.userAgent.toLowerCase())||
            /webkit/.test(navigator.userAgent.toLowerCase())||
            /opera/.test(navigator.userAgent.toLowerCase())) {
            //(当是火狐的时候)不显示(因为IE11采用的是火狐的内核)
            $(‘#toolInfo‘).show();
        }
        else {
            //IE11
            var ua = navigator.userAgent.toLowerCase();
            if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
                //浏览器类型  
                var browserType = "IE";
                //浏览器版本  
                var browserVersion = ua.match(/msie ([\d.]+)/) != null ? ua.match(/msie ([\d.]+)/)[1] : ua.match(/rv:([\d.]+)/)[1];

            } else {
                $(‘#toolInfo‘).show();
            }
        }

 

1.8.3

------------------------------------------------------------------------------------------------------------------------------

//当前如果不是IE浏览器或IE版本低于IE8的都要给出系统不支持的提示,并且给出下载安装包
        if ($.browser.msie) {
            if (parseFloat($.browser.version) < 8) {
                $(‘#toolInfo‘).show();
            }
        }
        else if ($.browser.mozilla) {
            //(当是火狐的时候)不显示(因为IE11采用的是火狐的内核)
        }
        else {
            $(‘#toolInfo‘).show();
        }

代码有点乱,

jquery 1.9 1.8 判断 浏览器(IE11,IE8,IE7,IE6)版本

原文:http://www.cnblogs.com/xiaoruilin/p/5726419.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!