Browser Detection


 

 

 

Source Code For browserdetect.html:
<html>
<head>
<script language="JavaScript">
<!--
// Browser Check
var browserName = navigator.appName;
var browserInfo = navigator.appVersion;
var browserVersion = parseInt(navigator.appVersion);
var browser = "";

if (browserName == "Netscape" && browserVersion == 5) {
	browser = "nn6";
}
else if (browserName == "Netscape" && browserVersion == 4){
	browser = "nn4";
}
else if (browserName == "Netscape" && browserVersion == 3){
	browser = "nn3";
}
else if (browserName == "Microsoft Internet Explorer" && browserVersion == 4
		&& navigator.appVersion.indexOf("MSIE 6.0") != -1){
	browser = "ie6";
}
else if (browserName == "Microsoft Internet Explorer" && browserVersion == 4
		&& navigator.appVersion.indexOf("MSIE 5.5") != -1){
	browser = "ie55";
}
else if (browserName == "Microsoft Internet Explorer" && browserVersion == 4
		&& navigator.appVersion.indexOf("MSIE 5.0") != -1){
	browser = "ie5";
}
else if (browserName == "Microsoft Internet Explorer" && browserVersion == 4){
	browser = "ie4";
}

//Handle browser-specific code

// -->

</script>
</head>
<body bgcolor=white>

<h3>Browser Detection</h3><br>

<script language="JavaScript">
<!--
document.write("<b>Browser Name:</b> " + browserName + "<br>");
document.write("<b>Browser Info:</b> " + browserInfo + "<br>");
document.write("<b>Major Version:</b> " +  browserVersion + "<br>");
document.write("<b>Actual Version:</b> " + browser + "<BR>");

document.write("<font color=\"red\" size=\"+2\">");
if (browser == "ie6") {
	document.write("Internet Explorer 6.0");
}
else if (browser == "ie55") {
	document.write("Internet Explorer 5.5");
}
else if (browser == "ie5") {
	document.write("Internet Explorer 5.0");
}
else if (browser == "nn6") {
	document.write("Netscape 6");
}
else if (browser == "nn4") {
	document.write("Netscape 4");
}
else {
	document.write("unspecified browser");
}
document.write("</font>");
// -->
</script>
</body>
</html>
Back