Xpode.com        Click here to Print this article.

Browser detection using JavaScript

There may be some situations where you need to detect the browser from website then you need to write this code.

				
<script type="text/javascript">

function whichname()
{
var bname = navigator.appName;
alert("You are using " + bname);
}

</script>

Some time you can have situation that you have to need the show the browser message to user then you will write this code.

----------------------------------------------
<script type="text/javascript">
var browsrName = navigator.appName;
if (browsrName.search(/netscape/i) == 0)
{
alert('you are using netscape');
}
else if (browsrName.search(/microsoft/i) == 0)
{
alert('you are using internet explore');
}
else
{
alert('you are using any other browser');
}
</script>
----------------------------------------------



http://
http://

Contributed by:
Rohit kakria
I am software developer, moderator of xpode.com

Resourse address on xpode.com
http://www.xpode.com/Print.aspx?Articleid=25

Click here to go on website