Monday, March 1, 2010

Browser detection using JavaScript

Browser detection allows you to find out what browser your viewer is using .

There are two objects often used for this,

1.navigator.appName

2.navigator.appVersion

The first one returns the name of the browser, the second returns the version of the browser.

ex:
function aa()
{
var browserName=navigator.appName;
if (browserName=="Netscape")
{
alert("Netscape User");
}
else
{
if (browserName=="Microsoft Internet Explorer")
{
alert("InterNet Explorer User");
}
else
{
alert("Other browser User");
}
}
}

1 comment:

  1. Good one...!!!
    But i didn't understand it properly,....can you please elaborate.
    visit my blog: http://greedywebtech.blogspot.com/

    ReplyDelete