How to find out if the user browser is Chrome with JavaScript?

Spread the love

Sometimes, we want to find out if the user browser is Chrome with JavaScript.

In this article, we’ll look at how to find out if the user browser is Chrome with JavaScript.

How to find out if the user browser is Chrome with JavaScript?

To find out if the user browser is Chrome with JavaScript, we can check the navigator.userAgent value.

For instance, we write

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

to check if 'Chrome' is in the user agent string and 'Google Inc' is in the vendor string to check if the page is loaded in Chrome.

Conclusion

To find out if the user browser is Chrome with JavaScript, we can check the navigator.userAgent value.

Leave a Reply

Your email address will not be published.