Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




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>
----------------------------------------------

Share this article   |    Print    |    Article read by 5029 times
Author:
Rohit kakria
I am software developer, moderator of xpode.com
Related Articles:
Related Interview Questions: No related interview question