Tag Archives: Detecting Browsers using Java Script

Detecting Browsers using Java Script

Hi All,

Although it is not a rocket science to get the browser details using any technology script, but i will show a very Object oriented way to display the browser details using java script.

Step 1: Create one JS file, Name it CheckBrowser.js

Step 2: Write the below code in the file.

function IsBrowser(){
var agt=navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.nav  = ((agt.indexOf(‘mozilla’)!=-1) && ((agt.indexOf(‘spoofer’)==-1)  && (agt.indexOf(‘compatible’) == -1))); // FireFox/Mozilla

// add your browsers detection code here.
// e.g this.ie=


Step 3: Add the js in the Html/JSP/ASP/PHP file.
// <![CDATA[
javascript” >
// ]]>

Step 4: Invoke the function in Object oriented way

var is = new IsBrowser();

R Vashi