Wednesday, 18 July 2012

Detect browser type & version using JQuery

The $.browser property provides information about the web browser that is accessing the page, as reported by the browser itself. It contains flags for each of the four most prevalent browser classes (Safari, Opera, Internet Explorer, Mozilla and Webkit) as well as version information.
This property will return “true”, if the current browser and the property flag are same.
  • $.browser.safari
  • $.browser.opera
  • $.browser.msie
  • $.browser.mozilla
  • $.browser.webkit      //As of JQuery 1.4

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

//Detect if the browser is IE6
if ( ($.browser.msie) && ($.browser.version == '6.0') ){
alert('IE 6')

No comments:

Post a Comment