EarthWeb
Developer.com
Site
windows 2000
visual c++
java
visual basic
javascripts
recommend it
 
Book
thinking in java
 
Interact
forum
guest book
jobs
jokes
what's new

share code
 
Resource
add resource
modify resource
new resource
 

[Internet Jobs]
-----
Java by E-mail:

Get the weekly e-mail highlights on Java!
-----

-

Detect browser type and version


Author: Real Gagnon
Author's WebSite: http://tactika.com/realhome/realhome.html


 <HTML>
 <HEAD>
 <SCRIPT LANGUAGE= "JavaScript">
 function isNetscape(v) {
   /*
   ** Check if the browser is Netscape compatible
   **    v  version number
   ** returns  true if Netscape and version equals or greater
   */
   return isBrowser("Netscape", v);
   }

 function isMicrosoft(v) {
   /*
   ** Check if the browser is Microsoft Internet Explorer compatible
   **    v  version number
   ** returns  true if MSIE and version equals or greater
   */
   return isBrowser("Microsoft", v);
   }

 function isBrowser(b,v) {
   /*
   ** Check if the current browser is compatible
   **  b  browser name
   **  v  version number (if 0 don't check version)
   ** returns true if browser equals and version equals or greater
   */
   browserOk = false;
   versionOk = false;

   browserOk = (navigator.appName.indexOf(b) != -1);
   if (v == 0) versionOk = true;
   else  versionOk = (v <= parseInt(navigator.appVersion));
   return browserOk && versionOk;
   }
 </SCRIPT></HEAD><BODY><FORM>
 <INPUT TYPE="button" 
        VALUE="Test for Netscape 4" 
        onClick="alert(isBrowser('Netscape', 4));">
 <INPUT TYPE="button" 
        VALUE="Test for IE3" 
        onClick="alert(isBrowser('Explorer', 0));">
 </FORM></BODY></HTML>



For more complete script to detect browser version, check the Netscape site

Posted On: 10-Jul-1999

internet.commerce



Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers