The Google Chrome User Agent

3rd September 2008 - 2 minutes read time

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.

navigator.userAgent

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:1.9.0.1) 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.

  1. <span id="useragent"></span>
  2. <script type="text/javascript">
  3. document.getElementById('useragent').innerHTML = navigator.userAgent;
  4. </script>

 

Add new comment

The content of this field is kept private and will not be shown publicly.