20
$(window).load(function () {
   if($.browser.msie && $.browser.version=="6.0") {
     // do stuff
   }
});

Just realized that $.browser has been depreciated in 1.3. What is the new method for detecting IE, specially IE6.

Kara
  • 6,115
  • 16
  • 50
  • 57
eozzy
  • 66,048
  • 104
  • 272
  • 428
  • 2
    `jQuery.browser` is not deprecated. Although it is no longer used by jQuery internally it's available to user scripts for the indefinite future: http://docs.jquery.com/Utilities/jQuery.browser – Crescent Fresh Dec 22 '09 at 04:27
  • The documentation says "Deprecated in jQuery 1.3 (see `jQuery.support`) The version number of the rendering engine for the user's browser.". – apaderno Dec 22 '09 at 04:39
  • 1
    *Feature detection* is much better than *browser sniffing*, what are you trying to achieve when your page is rendered by IE6? – Christian C. Salvadó Dec 22 '09 at 04:50
  • 2
    We need to all make a pact as web developers to boycott IE until people stop using it. – OneChillDude Apr 06 '13 at 16:50

3 Answers3

19

The jQuery documentation for jQuery.browser shows the following warning. (Emphasis is mine.)

Because $.browser uses navigator.userAgent to determine the platform, it is vulnerable to spoofing by the user or misrepresentation by the browser itself. It is always best to avoid browser-specific code entirely where possible. Instead of relying on $.browser it's better to use libraries like Modernizr.

The documentation page also says:

This property was removed in jQuery 1.9 and is available only through the jQuery.migrate plugin. Please try to use feature detection instead.

Even jQuery.support, which was suggested from the old documentation has the following warning. (Emphasis is mine.)

A collection of properties that represent the presence of different browser features or bugs. Intended for jQuery's internal use; specific properties may be removed when they are no longer needed internally to improve page startup performance. For your own project's feature-detection needs, we strongly recommend the use of an external library such as Modernizr instead of dependency on properties in jQuery.support.

The previous documentation for jQuery.support reported the following properties and values.

  • $.support.boxmodel is false in IE 6, and 7.
  • $.support.cssFloat is false for IE 6, 7 and 8; it is true in IE 9.
  • $.support.leadingWhitespace is false for IE 6, 7, and 8.
  • $.support.objectAll is currently false for IE 6, 7, and 8.
apaderno
  • 28,547
  • 16
  • 75
  • 90
  • 2
    Just for all others that find this comment, $.support.cssFloat is false for IE 6, 7 and 8. In IE 9 it is true. – Nemke Mar 01 '13 at 08:00
  • I know this answer is kind of old, but debugging in IE9 with Browser Mode IE7 has $.support.boxModel === true. Maybe it's because I'm using a browser mode in IE9?? – kand Mar 06 '13 at 16:07
6

hot from the documentation: We recommend against using this property, please try to use feature detection instead (see jQuery.support).

just somebody
  • 18,602
  • 6
  • 51
  • 60
1

Show the browser Information

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

Alert the version of IE's rendering engine that is being used. Will not work in jQuery 1.9 or later unless the jQuery Migrate plugin is included.

if ( $.browser.msie ) {
alert( $.browser.version );
}