0

I wanted to detect IE8 and 9 via JavaScript. All of them return as 7. I tried JQuery-1.8.2, but same results.

It returns "Compatible" version or something. If both IE8 and 9 versions use their IE version as 7, why they behave differently? Why MS labels it as 8 and 9 and send some other version details on the IP header?. Is this the expected behavior of IE?

I tried this too. http://msdn.microsoft.com/en-us/library/ms537509(v=vs.85).aspx

Can anyone give an explanation about this. Thanks.

sura2k
  • 7,365
  • 13
  • 61
  • 80

1 Answers1

1

You can find a solution Detect IE version (prior to v9) in JavaScript

See:

<!doctype html>
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
<head>

and then:

(function ($) {
    "use strict";

    // Detecting IE
    var oldIE;
    if ($('html').is('.ie6, .ie7, .ie8')) {
        oldIE = true;
    }

    if (oldIE) {
        // Here's your JS for IE..
    } else {
        // ..And here's the full-fat code for everyone else
    }

}(jQuery));
Community
  • 1
  • 1
Leon
  • 867
  • 7
  • 13