Over a million developers have joined DZone.

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

· Web Dev Zone

Start coding today to experience the powerful engine that drives data application’s development, brought to you in partnership with Qlik.

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;

Create data driven applications in Qlik’s free and easy to use coding environment, brought to you in partnership with Qlik.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}