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


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

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.