Friday, June 17, 2011

How to use JavaScript to determine the type of browser?

In order to make Web Applications can be worked in a variety of browsers. Depending on the differences of browsers, we need to adjust code, especially JavaScript code. Before doing this, at first we should use JavaScript to determine the type of current browser. Now we give the JavaScript code (To determine IE and 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;
}

No comments:

Post a Comment