Some of the features mentioned here, might not be available in the latest version of jQuery

How to detect browser type & version using jQuery

Author: satz | Date: October 6, 2010

jQuery.browser is one of the properties of the global jQuery Object. The property “$.browser” or “jQuery.browser” enables to detect which web browser is accessing the page. It is very useful while in need of serving unique contents for different browsers.

Following are the flags available for “jQuery.browser” property.

  • webkit
  • safari (deprecated)
  • opera
  • msie
  • mozilla

Usage of jQuery.browser property

$.browser.webkit
 $.browser.safari
 $.browser.opera
 $.browser.msie
 $.browser.mozilla

This property will return “true”, if the current browser and the property flag are same.

Detect browser version using jQuery

jQuery.browser.version is used to detect the browser version. It returns String. jQuery.browser.version is one of properties of the global jQuery Object.

Usage of “jQuery.browser.version” property

jQuery.browser.version

Example for jQuery.browser and jQuery.browser.version property

Detect if the browser is IE6

if ( ($.browser.msie) && ($.browser.version == '6.0') ){
 alert('IE 6')
 }

Notes:
jQuery official api reference states, “The $.browser property is deprecated in jQuery 1.3, but there are no immediate plans to remove it.”