An overview of jQuery.browser
Update: jQuery.version should have been jQuery.browser.version. Added Firefox 3.0.1
If you are a user of jQuery, you may be aware of the basic browser sniffer that comes with it. However, it may seem to return the wrong version number for certain browsers (Firefox and Safari in particular). This is because it returns the version number of the rendering engine (i.e. the part of the web browser that determines how a page should look and function). To help simplify things, I have created a table of common user agents and what jQuery returns:
Browser | jQuery.browser | jQuery.browser.version |
---|---|---|
Internet Explorer 6 | jQuery.browser.msie = true | 6.0 |
Internet Explorer 7 | jQuery.browser.msie = true | 7.0 |
Firefox 1.5 (first release) | jQuery.browser.mozilla = true | 1.8 or 1.8.0 |
Firefox 1.5.0.9 | jQuery.browser.mozilla = true | 1.8.0.9 |
Firefox 2.0 (first release) | jQuery.browser.mozilla = true | 1.8.1 |
Firefox 2.0.0.9 | jQuery.browser.mozilla = true | 1.8.1.9 |
Firefox 3.0 | jQuery.browser.mozilla = true | 1.9 |
Firefox 3.0.1 | jQuery.browser.mozilla = true | 1.9.0.1 |
Safari 2.0.2 | jQuery.browser.safari = true | 416.11 / 416.12 |
Safari 2.0.4 | jQuery.browser.safari = true | 418.x - 419 |
Safari 3.0.x | jQuery.browser.safari = true | 522+, 522.x, 523.x |
Safari 3.1.x | jQuery.browser.safari = true | 525.x, 526+ |
Opera x | jQuery.browser.opera = true | x |
I have listed Opera as 'Opera x' as the version number 'x' is always returned by jQuery.browser.version (so no extra work is required, unlike Firefox and Safari).
This table is based on information from UserAgentString.com. There is a Firefox 1.5.0.12, but I am unsure of the version number, plus there are Safari versions with a slightly different rendering engine version number (i.e. 2.0.2 is not always 416.11). Basically, with Safari, if the version number returned is less than 418, it is Safari 2 or lower and if it is around 525/526 it is Safari 3.1.
Comments
Thanks for posting this, its a good reference!