We use cookies to collect and analyze information on site performance and usage,
to provide social media features and to enhance and customize content and advertisements.
Detecting if a feature is present or not
We test for a known feature to decide the browser type.
This technique is not very good because a browser can alter its name to allow
a better compatibility.
<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