Detecting the visitor's browser in javascript

by Nithya 2011-03-15 18:17:39

Detecting the visitor's browser in javascript

There are different types of browsers with different versions used by the visitor to access a website. For a server side program there is nothing to do or special care to be taken as the code remains in severs side. However for client side tags or scripts as they gets executed at visitor end they have to give equal output for different browsers used by visitors.

Here is the code to display details about the browser


<table width='100%' border='0' cellspacing='1' cellpadding='0'>

<script type="text/javascript">
var st;
st="<tr><td class=data>UserAgent </td><td class=data>"+ navigator.userAgent + "</td></tr>";
st=st + "<tr><td class=data>appName </td><td class=data>"+ navigator.appName + "</td></tr>";
st=st + "<tr><td class=data>appVersion</td><td class=data>"+ navigator.appVersion + "</td></tr>";
st=st + "<tr><td class=data>browserLanguage</td><td class=data>"+ navigator.browserLanguage + "</td></tr>";
st=st + "<tr><td class=data>platform</td><td class=data>"+ navigator.platform + "</td></tr>";

document.write(st);
</script>
</table>

Tagged in:

1483
like
0
dislike
0
mail
flag

You must LOGIN to add comments