How to detect IE7 and IE8 using jQuery.support

前端 未结 12 1237
忘掉有多难
忘掉有多难 2020-12-08 10:46

How can I detect IE 7 and IE 8 using jQuery.support properties?

Is it possible to detect the browser versions using jQuery.support or just those blah blah blah brows

相关标签:
12条回答
  • 2020-12-08 11:06
    if (jQuery.support.leadingWhitespace == false){
    
    ... code for IE7-IE8 ...
    
    }
    else {
    ... 
    }
    
    0 讨论(0)
  • 2020-12-08 11:07

    Use jQuery.browser.version instead of support

    0 讨论(0)
  • 2020-12-08 11:10

    One trick I found is to add Conditionnal Tags in the HTML

    <!--[if lt IE 7]><body class="ie ie6 lte9 lte8 lte7"><![endif]-->
    <!--[if IE 7]><body class="ie ie7 lte9 lte8 lte7"><![endif]-->
    <!--[if IE 8]><body class="ie ie8 lte9 lte8"><![endif]-->
    <!--[if IE 9]><body class="ie ie9 lte9"><![endif]-->
    <!--[if !IE]><!--><body class="not-ie"><!--<![endif]-->
    

    Then use JQuery like this :

    $('body.ie7')
    

    It also helps for CSS on IE specific

    body.ie6{ margin: 0; }
    

    I don't know if it's good for you but anyways, that's still an option.

    0 讨论(0)
  • 2020-12-08 11:15

    Be careful with the following because it also includes IE10:

    if ($.browser.msie && $.browser.version.substr(0,1)<7) {
    //<IE7
    }
    

    better use:

    if ($.browser.msie && parseInt($.browser.version,10)<7) {
    //<IE7
    }
    
    0 讨论(0)
  • 2020-12-08 11:15
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) { 
        var ieversion = new Number(RegExp.$1);
        alert(ieversion < 9);
    }
    
    0 讨论(0)
  • 2020-12-08 11:16

    Try $.browser, it will let you know if browser version is less than IE9

     var isM = false;
     $.each($.browser, function (i, val) {
        if ($.browser.msie && parseInt(val) < 9) isM = true;
    });
    
    0 讨论(0)
提交回复
热议问题