Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

JavaScript: How to use JavaScript to determine the type of browser?

DZone's Guide to

JavaScript: How to use JavaScript to determine the type of browser?

· Web Dev Zone ·
Free Resource

Learn how error monitoring with Sentry closes the gap between the product team and your customers. With Sentry, you can focus on what you do best: building and scaling software that makes your users’ lives better.

In order to make Web Applications work in a variety of browsers and take advantage of their unique features, you must first determine the browser.  Depending on the browser, we need to adjust the code, especially the JavaScript code. Before doing this, can use JavaScript to determine the type of browser being used. Here is an example of two functions that determine if a user's browser is IE or Firefox:

function isIE() {
 var ie = (navigator.userAgent.indexOf("MSIE") != -1);
 
 return ie;
}

function isFireFox() {
 var fireFox = (navigator.userAgent.indexOf("Mozilla") != -1 ||
  navigator.userAgent.indexOf("FireFox") != -1);
 
 return fireFox;
}

What’s the best way to boost the efficiency of your product team and ship with confidence? Check out this ebook to learn how Sentry's real-time error monitoring helps developers stay in their workflow to fix bugs before the user even knows there’s a problem.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}