Detect Internet Explorer 6 or below in jQuery

前端 未结 13 2403
野的像风
野的像风 2020-12-12 17:44

I\'m new to jquery and was wondering: is a simple way to detect whether a browser is Internet Explorer 6 or below?

相关标签:
13条回答
  • 2020-12-12 18:21

    If ActiveXObject exists and XMLHttpRequest does not, it's IE6:

    /* IE6 Check */
    (!!window.ActiveXObject && !window.XMLHttpRequest) ? true : false;
    

    In IE7, it would be:

    (!!window.ActiveXObject && !!window.XMLHttpRequest) ? true: false;
    

    References

    • JavaScriptKit: AJAX
    0 讨论(0)
  • 2020-12-12 18:21

    i always used this solution

    http://sinfinity.pl/blog/2012/02/12/detect-internet-explorer-and-browser-version-in-jquery/

    0 讨论(0)
  • 2020-12-12 18:22

    You could also ask IE directly.

    <!--[if lte IE 6]>
    <script type="text/javascript">
      var isRunningIE6OrBelow = true;
    </script>
    <![endif]-->
    
    0 讨论(0)
  • 2020-12-12 18:23

    I often check the version of a browser. The .support method is great, but it doesn't really help when you need to hide selects when there's an overlay. There is no "supports selects are windowed controls". You just need to check the browser version, so I would say err towards the .support method where you can, and use the .browser where necessary.

    0 讨论(0)
  • 2020-12-12 18:24

    Very nice way to detect IE is:

    if ('v'=='\v') {
       welcome to IE )) 
    }
    

    Unfortunately it can't recognize its version but it's not always nessecary.

    0 讨论(0)
  • 2020-12-12 18:25

    Try this out:

     jQuery.each(jQuery.browser, function(i, val) {
      $("<div>" + i + " : <span>" + val + "</span>")
                .appendTo(document.body);
    });
    

    if you need more info refer to this:

    http://docs.jquery.com/Utilities/jQuery.browser

    0 讨论(0)
提交回复
热议问题