#1101 closed enhancement (fixed)
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 (last modified by )
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!
Change History (6)
comment:1 Changed 16 years ago by
comment:2 follow-up: 3 Changed 16 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in SVN rev [1809].
comment:3 follow-up: 4 Changed 16 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Replying to 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]); }
comment:4 follow-up: 5 Changed 16 years ago by
Component: | ajax → core |
---|---|
Resolution: | → fixed |
Status: | reopened → closed |
comment:5 Changed 16 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
Replying to john:
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"; };
comment:6 Changed 16 years ago by
Description: | modified (diff) |
---|---|
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: