This code is in the body of an asp page. I can't seem to get an alert box to fire when using an older version of Netscape (v 4.08). Not sure if I'm going about it right or not this is the first time I've tried to build a sniffer. Can someone tell me what I'm doing wrong?
Code:
<script language = javascript>
function Is() {
// convert all characters to lowercase to simplify testing
var agent = navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
// *** BROWSER VERSION ***
is_major = parseInt(navigator.appVersion);
is_minor = parseFloat(navigator.appVersion);
//Netscape check
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav40 = (is_nav && (is_major == 4) && (agent.indexOf('4.0 ')!=-1));
var is_nav401 = (is_nav && (is_major == 4) && (agent.indexOf('4.01')!=-1));
var is_nav02 = (is_nav && (is_major == 4) && (agent.indexOf('4.02')!=-1));
var is_nav03 = (is_nav && (is_major == 4) && (agent.indexOf('4.03')!=-1));
var is_nav04 = (is_nav && (is_major == 4) && (agent.indexOf('4.04')!=-1));
var is_nav05 = (is_nav && (is_major == 4) && (agent.indexOf('4.05')!=-1));
var is_nav06 = (is_nav && (is_major == 4) && (agent.indexOf('4.06')!=-1));
var is_nav07 = (is_nav && (is_major == 4) && (agent.indexOf('4.07')!=-1));
var is_nav08 = (is_nav && (is_major == 4) && (agent.indexOf('4.08')!=-1));
var is_nav450 = (is_nav && (is_major == 4) && (agent.indexOf('4.50')!=-1));
var is_nav451 = (is_nav && (is_major == 4) && (agent.indexOf('4.51')!=-1));
var is_nav46 = (is_nav && (is_major == 4) && (agent.indexOf('4.6')!=-1));
var is_nav461 = (is_nav && (is_major == 4) && (agent.indexOf('4.61')!=-1));
var is_nav47 = (is_nav && (is_major == 4) && (agent.indexOf('4.7')!=-1));
var is_nav472 = (is_nav && (is_major == 4) && (agent.indexOf('4.72')!=-1));
var is_nav473 = (is_nav && (is_major == 4) && (agent.indexOf('4.73')!=-1));
var is_nav474 = (is_nav && (is_major == 4) && (agent.indexOf('4.74')!=-1));
var is_nav475 = (is_nav && (is_major == 4) && (agent.indexOf('4.75')!=-1));
var is_nav476 = (is_nav && (is_major == 4) && (agent.indexOf('4.76')!=-1));
var is_nav48 = (is_nav && (is_major == 4) && (agent.indexOf('4.8')!=-1));
var is_nav6up = (is_nav && is_minor >= 6);
//IE check
var is_ie = (agent.indexOf("msie") != -1);
//MAC check
var is_macie = (is_mac && is_ie);
//Mosiac check
var is_mosiac = (agent.indexOf("mosiac") !=- 1);
}
var is = new Is();
//dynamically generate HTML markup which is optimized for the current browser
if (is_nav2) || (is_nav3) || (is_nav4) || (is_nav40) || (is_nav401) || (is_nav02) || (is_nav03) || (is_nav04) || (is_nav05) || (is_nav06) || (is_nav07) || (is_nav08) || (is_nav450) || (is_nav451) || (is_nav46) || (is_nav461) || (is_nav47) || (is_nav472) || (is_nav473) || (is_nav474) || (is_nav475) || (is_nav476) || (is_nav48) {
alert("This site is incompatible with Netscape 4.7 and below. Please Upgrade to Netscape 6 at [URL unfurl="true"]www.netscape.com");[/URL]
}
else if (is_nav6up) {
document.write("<input type=hidden name=ScreenSize value=\"" + self.screen.width +"\">");
document.write("<input type=hidden name=Browser value=\"ns7up\">");
}
else if (is_ie) {
document.write("<input type=hidden name=ScreenSize value=\"" + self.screen.width +"\">");
document.write("<input type=hidden name=Browser value=\"ie\">");
}
else if (is_macie) {
document.write("<input type=hidden name=ScreenSize value=\"" + self.screen.width +"\">");
document.write("<input type=hidden name=Browser value=\"macie\">");
}
if (is_mosiac) {
alert("This site is incompatible with Mosaic. Please try IE at [URL unfurl="true"]www.microsoft.com/windows/ie/default.asp[/URL] or Netscape 6 at [URL unfurl="true"]www.netscape.com");[/URL]
}
else {
alert("Unrecognized Browser Detected");
}
</script>