The negative side of having a new (and promisingly become popular) browser, no matter how good it can be, is you’ll have to test your web apps with it among many others.
Probably, the first step is to detect the browser from JavaScript code by parsing browser’s user agent, and here is what of Google Chrome.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.2.149.27 Safari/525.13
I guess old JavaScript codes can mistakenly tell it Safari like when running the code snippet below using JQuery’s browser utility.
1 2 3 4 | $.each($.browser, function(i, val) { $("<div>" + i + " : <span>" + val + "</span></div>") .appendTo(document.body); }); |

It may be no problem until you find something wrong when your apps running on Chrome only. So, here is the code line to detect Chrome generally:
1 | var is_chrome = /chrome/.test( navigator.userAgent.toLowerCase() ); |
We’ll have to change the JQuery browser utility to support Chrome detection as follows:
1 2 3 4 5 6 7 8 9 10 11 | var userAgent = navigator.userAgent.toLowerCase(); // Figure out what browser is being used jQuery.browser = { version: (userAgent.match( /.+(?:rv|it|ra|ie|me)[\/: ]([\d.]+)/ ) || [])[1], chrome: /chrome/.test( userAgent ), safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ), opera: /opera/.test( userAgent ), msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ), mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent ) }; |
Now, correct result shows on test screen:

Just one notice: Current version of JQuery (1.2.6) is treating Chrome as if it was Safari and basically no serious problem has been found yet. Modifying browser detection can cause the lib render pages/elements incorrectly for it has no knowledge of Chrome’s rendering engine. To keep compatibility, you can change line 7 back to:
7 | safari: /webkit/.test( userAgent ), |
Recommended Reading
jQuery CompressedThe books examples are verified to work with jQuery 1.7jQuery is a JavaScript API that makes it easy to make your HTML pages come to life.... Read More >
Learning jQuery, Third EditionStep through each of the core concepts of the jQuery library, building an overall picture of its capabilities. Once you have thoroughly covered the ba... Read More >
How Google Tests SoftwarePioneering the Future of Software Test
Do you need to get it right, ... Read More >






4