Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Getting the Browser Information using Java Script.

Author: DevASP
Download Source Code : 591_BrowserInfo.zip

If your visitors are not quite sure the details of the browser they are using, you can show them with this neat little script. The script will produce a table that shows the browser name, version information etc.........

 

Steps you will do.

 

Start visual studio and create a new web application.

 

Open the HTML design of your web page and add the following JavaScript functions before closing the head tag.

 

<script language ="JavaScript">

 

 

var navName = navigator.appName ;

var brVer = navigator.userAgent; var brNum; var reg = new RegExp('/');

function verNumIE() {

   var brVerId = brVer.indexOf('MSIE');

   brNum = brVer.substr(brVerId,8);

}

function verNumOt() {

   var brVerId = brVer.search(reg);

   brNum = brVer.substring(brVerId+1);

}

 

 

if (navigator.appName == 'Microsoft Internet Explorer') {

  verNumIE() ;

} else {

  verNumOt() ;

}

document.write("<CENTER>");

document.write("<TABLE BORDER=2>");

document.write("<CAPTION Align=Top><b>Your Browser Informations</b></CAPTION>");

document.write("<Tr>");

document.write("<td bgcolor=#C0C0C0><b>Browser Name : </b></td>");

document.write("<td>",navName,"</td>");

document.write("</Tr>");

document.write("<Tr>");

document.write("<td bgcolor=#C0C0C0><b>Platform Name : </b></td>");

document.write("<td>",navigator.platform,"</td>");

document.write("</Tr>");

document.write("<Tr>");

document.write("<td bgcolor=#C0C0C0><b>Browser Version : </b></td>");

document.write("<td>",brNum,"</td>");

document.write("</Tr>");

document.write("<Tr>");

document.write("<td bgcolor=#C0C0C0><b>Is Java enabled ? : </b></td>");

if ( !(navigator.javaEnabled()) ) {

  java="No" ;

} else {

  java="Yes" ;

}

document.write("<td>",java,"</td>");

document.write("</Tr>");

document.write("</TABLE>");

document.write("</CENTER>");

 

 

</script>

 

Now add the following HTML code to design the web page.

 

<center>

<font face="arial, helvetica">Dont forget to visit Devasp.com<br>

<a href="http://www.devasp.com">www.devasp.com</a></font>

</center>

 

 

Run your application and see your browser information.

 

 

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Creating a Banner Rotator using Java Script.

Disclaimer - Privacy
© 2002-2017 DevASP.net