Detecting IE using jQuery

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.

Leave a Comment