How to identify a certain browser



OK, now we come to the real stuff. If we have to assume that it's a too long way for the prophet (the browser programers) to come to the mountain (the web specifications) we have to move the mountain instead...

   Differencing between different browsers is more or less impossible if you do not have access to the low level functions of the server that holds your web pages and if you don't use javascript. As the most of you probably have your web pages managed by a remote site (like GeoCities, AOL, [endless list]), the latter one is your only possibility. So if the visitors to your page use a browser with disabled javascript or with no javascript functionalities at all - you will not be able to identify them at all inside your HTML code. Nevertheless you should take care that even those visitors can see the contents of your page!


   The following very short Javascript allows you to determine between the two major classes of web browsers:
  <script language="JavaScript">
  <!--
  if (navigator.appName.substring(0,8) != 'Netscape')
    document.write('You probably use Microsoft IExplorer\n')
  else
    document.write('You probably use Netscape or Opera>\n');
  // -->
  </script>

As you can see on my browsertest page, I used the javascript method substring(0,8) on the object navigator.appName to identify the browser. Here is a list of the different contents you might expect in this string object:

Browserversion navigator.appName

Netscapev3.01-v4.6"Netscape"
Operav3.50b9-v3.60"Netscape"
MS IExplorerv4.0"Microsoft Internet Explorer"


Well isn't there a better possibility and perhaps a more detailed analysis possible??
Yes! The object navigator.userAgent gives us a lot more information about the type and the version of the browser, it even tells us on which operating system the browser runs:

BrowserVersion navigator.userAgent(1)

Netscapev1.12, MacOS"Mozilla/1.12(Macintosh; I; PPC)"?
 v3.01"Mozilla/3.01 (Win16; I)"
 v4.01, OEM "Mozilla/4.01 [de]C-DT (Win95; I)"?
 v4.04, OEM "Mozilla/4.0 (compatible; MSIE 4.01; Windows 95; DT)"?
 v4.05, SunOS"Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u)"
 v4.06, WinNT"Mozilla/4.06 [en] (WinNT; I)"
 v4.07, Linux"Mozilla/4.07 [en] (X11; I; Linux 2.0.36 i586)"
 v4.07, MacOS"Mozilla/4.07 (Macintosh; I; PPC, Nav)"?
 v4.5 "Mozilla/4.5 [en] (WinNT; I)"
 v4.5, OEM"Mozilla/4.5 [de]C-DT (Win98; I)"?
 v4.5, OEM"Mozilla/4.5 [de]C-CCK-MCD QXW03201 (Win95; I)"?
 v4.6 "Mozilla/4.6 [en] (WinNT; I)"
 v4.79 modified"Mozilla/4.79 [en]C-CCK-MCD {SillyDog} (Windows NT 5.0; U)"
 v6 "Mozilla/5.0 (Windows; U; WinNT4.0; de-DE; m18) Gecko/20001106 Netscape6/6.0"
 
Operav3.0 "Mozilla/3.0 (compatible;Opera/3.0; Windows 95)"?
 v3.50 "Mozilla/4.0 (compatible; Opera/3.0; 4.0) 3.50 [en]"
 v3.50b9 "Mozilla/3.0 (compatible; Opera/3.0; Windows NT 4.0) 3.50b9"
 v3.51 "Mozilla/4.0 (compatible; Opera/3.0; Windows NT 4.0) 3.51 [en]"
 v3.60 "Mozilla/4.0 (Windows NT 4.0;US) Opera 3.60 [en]"
 v5.12 native"Opera/5.12 (Windows 2000; U) [en]"
 v5.12 as IE"Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 5.12 [en]"
 v5.12 as Mozilla 3"Mozilla/3.0 (Windows 2000; U) Opera 5.12 [en]"
 v5.12 as Mozilla 5"Mozilla/5.0 (Windows 2000; U) Opera 5.12 [en]"
 v5.12 as Netscape 4.76"Mozilla/4.76 (Windows 2000; U) Opera 5.12 [en]"
 v6.02 native"Opera/6.02 (Windows 2000; U) [en]"
 v6.02 as IE 5.0"Mozilla/4.0 (compatible; MSIE 5.0; Windows 2000) Opera 6.02 [en]"
 v6.02 as Mozilla 3"Mozilla/3.0 (Windows 2000; U) Opera 6.02 [en]"
 v6.02 as Mozilla 4.78"Mozilla/4.78 (Windows 2000; U) Opera 6.02 [en]"
 v6.02 as Mozilla 5"Mozilla/5.0 (Windows 2000; U) Opera 6.02 [en]"
 
IExplorerv3.0"Mozilla/2.0 (compatible; MSIE 3.0; Windows 95)"?
  v3.0, AOL"Mozilla/2.0 (compatible; MSIE 3.0; AOL 3.0; Windows 3.1)"?
  v3.02"Mozilla/2.0 (compatible; MSIE 3.02; Update a; Windows 95)"?
  v3.02, AOL"Mozilla/2.0 (compatible; MSIE 3.02; Update a; AK; AOL 3.0; Windows 95)"?
  v4.01"Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)"?
  v4.01"Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)"
  v4.01, OEM"Mozilla/4.0 (compatible; MSIE 4.01; Windows 95; DT)"
  v4.01, OEM"Mozilla/4.0 (compatible; MSIE 4.01; Windows 95; Mannesmann Arcor)"
  v5.0b"Mozilla/4.0 (compatible; MSIE 5.0b2; Windows 98)"
  v5.5"Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; T312461)"
 
Others "NetCruiser/V2.1.1"?
  "Scooter/1.0scooter@pa.dec.com"?
  "TeleportPro/1.28"?
  "Mozilla/3.0 WebTV/1.2 (compatible; MSIE 2.0)"?
  "Mozilla/3.0(compatible;MuscatFerret/1.4.1;olly@muscat.co.uk)"?
  "Lycos_Spider_(T-Rex)/3.0"?
This table is not - and will never be - complete. It only should give you a slight idea of the zoo out there. Most browser information has been extracted from the recent (Jan-Mar 1999) log file of a web page - so be aware that they all might still be around!!!


So, what idea would hit your mind regarding this table?
There is a javascript function coupled to the string object called string.indexOf("substring") which returns the position of a given substring in the string object or the value -1 if the substring is not found. A brilliant idea would be to search for the substrings "MSIE" and "Opera" respectively, because even though Opera is a little bit inconsistent with its own identification in this object - but finally it always tells us its name. BUT have a look at the last column of the table. The green sign marks those browsers which have the indexOf implemented. As you can see the programmers of Opera forgot to implement this feature in the 3.50 version of their browser (A question mark is noted for browsers to which I know the identification but not their javascript capabilities. As they are closely related to browsers that do understand the commands in question I suppose they do as well - but who knows...). Well they were so kind to at least implement the substring function that gives us
navigator.userAgent.substring(25,30) = 'Opera'
at least for the versions v3.50-beta9 and v3.51. In their newest release these same programmers decided to confuse us again and now we get
navigator.userAgent.substring(25,30) = '.0;US'
So what? Let's forget this stupid v3.50-beta9 of Opera? I myself haven't made up my mind in this point yet - but probably this is a reasonable thing to do. Since it only has been available a very short time before v3.51 was released and every registered user was notified of this update (they forgot the announcement of v3.60 though) it should have been an easy thing to download the 1.3 MB and update to a newer version. With this in mind we can create javascripts that will closely identify the browser visiting your page.
Writing and testing the code below on different browsers I had to figure out that theory and reality are again largely separated. This time it is Microsoft's Internet Explorer in the version 3.02 that was falsely identified as Netscape of unknown version. This is due to a number of bugs in the javascript interpreter in just this browser - but now it should work on a very broad range of browsers...
Here is the accurate and quite save version:
  <script language="JavaScript">
  <!--
  if (navigator.useragent == '')
    document.write('I might be wrong - but you probably use Microsoft IExplorer v3.02 or earlier\n')
  else 
   { if (navigator.userAgent.substring(25,30) == 'Opera')
       document.write('You use Opera, probably in a version prior or equal to v3.51\n')
     else
      { if (navigator.userAgent.indexOf('Opera') != -1)
          document.write('You use Opera in a version greater than v3.51\n')
        else
         { if (navigator.appName.substring(0,9) == 'Microsoft')	
            { var dummy = navigator.userAgent.substring(navigator.userAgent.indexOf('MSIE')+5,navigator.userAgent.length);
              document.write('You use Microsoft Internet Explorer v.'+dummy.substring(0,dummy.indexOf(";"))+'\n');
            }
           else 
            { if (navigator.appName.substring(0,8) == 'Netscape') 
               { if (navigator.userAgent.substring(0,7) == 'Mozilla')
                   document.write('You use Netscape Navigator v.'+navigator.userAgent.substring(8,11)+'\n')
                 else  
                   document.write('What the hell! I do not know your browser!\n')
               }	 
              else  
                document.write('What the hell! I do not know your browser!\n')
            }	  
         }   
      }
    }
  // -->
  </script>
  

Another correction to the original version of this script was neccessary when Stefan Münz, author of the german HTML guide "SelfHTML" reported me the fact that Opera v3.50 again has a different way of showing its identity...

2000-11-15: It finally is here! Netscape v6 was released as a non-beta version. However, it identifies itself as a version 5.0 software!

Of course you can use the identification of the different browsers for something more useful than to inform the user which browser he is using right now - I believe most users have at least a faint idea of that....
You can use the differentiation for example to load different external CSS style files which you have optimized for the use with different browsers (this was actually done on these pages). Or you might branch to completely different HTML pages depending on the browser used. (Of course you also could give the user a recommendation to update his browser, if it really is an outdated version)
BUT don't forget that everything on this page only works if and when javascript is enabled in the browsers options. So if you have really paranoic guests on your page with javascript disabled it might be nice for them to also find something. The same holds true for search robots from internet directories and search engines like AltaVista, Yahoo etc. I'm not sure but I really much doubt that these programs do interpret javascript and even if so, the identification might be difficult...


browsers.htmlSome very nasty behaviours I discovered using different browsers...
browsertest.htmlLet this little page check the compatibility of your browser's javascript functions...
incompatibilities.htmlCSS style sheets give a nice touch to your web pages - if only the browsers would know what to do with them...
index.htmlThe main page of this project.

So much for this page! If you are missing something OR have some own experiences you would like to share, just send me a mail!

send me an email