As the new Google web browser was released last night (I'm writing this post using the new browser) I thought it would be good to update our readers on the user agent string that this web browser has.
The user agent of any browser can be found out by using the userAgent property of the navigator object. This is available in most modern browsers and is thankfully also present in Google Chrome.
As an example the user agent for FireFox 3 on a Windows XP machine looks like this.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:184.108.40.206) Gecko/2008070208 Firefox/3.0.1
Using the same code, and the same machine, the user agent produced by Google Chrome is as follows.
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
So detecting it should only be a case of looking for the word "chrome". Just like this:
var ischrome = navigator.userAgent.indexOf("Chrome")? true : false;
If you want to see what the user agent is on your machine then paste this code into a web page and hit refresh. It is quite a basic bit of code and should work in most browsers.