[SOLVED] JavaScript: How to find out if the user browser is Chrome?

Issue

I need some function returning a boolean value to check if the browser is Chrome.

How do I create such functionality?

Solution

Update: Please see Jonathan’s answer for an updated way to handle this. The answer below may still work, but it could likely trigger some false positives in other browsers.

var isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);

However, as mentioned User Agents can be spoofed so it is always best to use feature-detection (e.g. Modernizer) when handling these issues, as other answers mention.

Answered By – Rion Williams

Answer Checked By – Willingham (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published.