Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 17,669 times

Related Categories

Browser Detect

nzjonboy

Here's a quick script that will give you the browser name and version.

 var useragent = navigator.userAgent;
 var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;
 var pos = useragent.indexOf('MSIE');
 if (pos > -1) {
   bVer = useragent.substring(pos + 5);
   var pos = bVer.indexOf(';');
   var bVer = bVer.substring(0,pos);
 }
 var pos = useragent.indexOf('Opera');
 if (pos > -1)    {
   bVer = useragent.substring(pos + 6);
   var pos = bVer.indexOf(' ');
   var bVer = bVer.substring(0, pos);
 }
 if (bName == "Netscape") {
   var bVer = useragent.substring(8);
   var pos = bVer.indexOf(' ');
   var bVer = bVer.substring(0, pos);
 }
 if (bName == "Netscape" && parseInt(navigator.appVersion) >= 5) {
   var pos = useragent.lastIndexOf('/');
   var bVer = useragent.substring(pos + 1);
 }
 document.writeln('<b>Browser Name: </b>' + bName + '<br>');
 document.writeln('<b>Browser Version: </b>' + bVer + '<br>')

Comments

  • How to detect an IE based web browser?

    Posted by Junesfore on 12 Aug 2005

    Well, if a browser with IE core, we cann't make out which brower it is. That is, we open a page with IExplorer or with some third-party web browser such as Crazy Browser or Maxthon Browser, all the i...