Side navigation
#1101 closed enhancement (fixed)
Opened April 05, 2007 02:39PM UTC
Closed July 15, 2007 03:11PM UTC
Last modified March 15, 2012 05:30PM UTC
Support of $.browser.version
Reported by: | alexo | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.1.4 |
Component: | core | Version: | 1.1.3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
It would be very useful if jQuery could provide a property for retrieving the current browser version... Currently, I cannot find out if, for instance, the browser is msie6 or msie7..
Thank you!
Attachments (0)
Change History (6)
Changed April 28, 2007 03:31PM UTC by comment:1
Changed April 28, 2007 03:34PM UTC by comment:2
resolution: | → fixed |
---|---|
status: | new → closed |
Fixed in SVN rev [1809].
Changed May 01, 2007 10:43AM UTC by comment:3
resolution: | fixed |
---|---|
status: | closed → reopened |
Replying to [comment:2 john]:
You detect the browser engine (gecko, webkit) from user agent, it's named to browser type (browser.mozilla, browser.safari), and the browser.version contains the browser build or version number (firefox, safari). If you detect the engine, why not detect the engine's number? Example the browser.mozilla is true under Mozilla, Firefox, Netscape, Flock etc. browsers but the browser.version contains the Firefox version number.
And the script currently halts if not match.
var browsers = { //Internet Explorer "Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)": "6.0", "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1; .NET CLR 1.1.4322; InfoPath.1; .NET CLR 2.0.50727)": "7.0", //Browsers with Gecko engine //Mozilla "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.12) Gecko/20050915" : "1.7.12", //Firefox "Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3": "1.8.1.3", //Netscape "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20070321 Netscape/8.1.3" : "1.7.5", //Flock "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.11) Gecko/20070321 Firefox/1.5.0.11 Flock/0.7.12" : "1.8.0.11", //Opera browser "Opera/9.20 (X11; Linux x86_64; U; en)": "9.20", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; en) Opera 9.20" : "9.20", "Mozilla/5.0 (Windows NT 5.1; U; pl; rv:1.8.0) Gecko/20060728 Firefox/1.5.0 Opera 9.20": "9.20", //WebKit engine "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; sv-se) AppleWebKit/418.9 (KHTML, like Gecko) Safari/419.3": "418.9", "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; en) AppleWebKit/418.8 (KHTML, like Gecko) Safari/419.3" : "418.8", "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; sv-se) AppleWebKit/312.8 (KHTML, like Gecko) Safari/312.5": "312.8", //Other user agent string "Other browser's user agent 1.0":null }; for (var i in browsers){ v = i.match(/.+(?:rv|it|ra|ie)[/: ]([d.]+)/i); version = v? v[1]:null; console.log([version==browsers[i], browsers[i], version]); }
Changed May 05, 2007 05:57PM UTC by comment:4
component: | ajax → core |
---|---|
resolution: | → fixed |
status: | reopened → closed |
Replying to [comment:3 hobbit]:
Committed in SVN rev [1872].
Changed June 04, 2007 11:35AM UTC by comment:5
resolution: | fixed |
---|---|
status: | closed → reopened |
Replying to [comment:4 john]:
Replying to [comment:3 hobbit]: Committed in SVN rev [1872].
The script throws an error if the match method returns null. The null[1] expression isn't valid. The modification to jQuery would be:
new function() { var b = navigator.userAgent.toLowerCase(), v = b.match(/.+(?:rv|it|ra|ie)[\\/: ]([\\d.]+)/); // Figure out what browser is being used jQuery.browser = { //If not match, the version contains null value. version: v? v[1]:v, //v && v[1] safari: /webkit/.test(b), opera: /opera/.test(b), msie: /msie/.test(b) && !/opera/.test(b), mozilla: /mozilla/.test(b) && !/(compatible|webkit)/.test(b) }; // Check to see if the W3C box model is being used jQuery.boxModel = !jQuery.browser.msie || document.compatMode == "CSS1Compat"; };
Changed July 15, 2007 03:11PM UTC by comment:6
description: | It would be very useful if jQuery could provide a property for retrieving the current browser version... Currently, I cannot find out if, for instance, the browser is msie6 or msie7..\ \ \ Thank you!\ → It would be very useful if jQuery could provide a property for retrieving the current browser version... Currently, I cannot find out if, for instance, the browser is msie6 or msie7.. \ \ \ Thank you! \ |
---|---|
milestone: | 1.1.3 → 1.1.4 |
resolution: | → fixed |
status: | reopened → closed |
version: | 1.1.2 → 1.1.3 |
Fixed in SVN.
I think I've finally made one that I'm pleased with. It matches the versions of all the browsers that we support, and is very short. Here's a full test:
the addition to jQuery would be: