DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Benoit has posted 48 posts at DZone. View Full User Profile

Detect Google Chrome

09.02.2008
| 3213 views |
  • submit to reddit
        Detect 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

<a href="http://www.ab-d.fr/">Source: </a><a href="http://www.ab-d.fr/date/2008-09-02/">Detect navigator Google Chrome (webkit, safari)</a>    

Comments

Randall Goya replied on Thu, 2008/08/21 - 5:48pm

oops, I changed the var name but forgot to update it :DOH: -> var nav = navigator.userAgent; var ischrome = nav.indexOf("Chrome")? true : false; or var nav = navigator.appVersion; var ischrome = nav.indexOf("Chrome")? true : false;

Randall Goya replied on Thu, 2008/08/21 - 5:48pm

all you need to do is var nav = navigator.userAgent; var ischrome = ua.indexOf("Chrome")? true : false; or var nav = navigator.appVersion; var ischrome = ua.indexOf("Chrome")? true : false; http://www.w3schools.com/js/tryit.asp?filename=try_dom_navigator