Ed_CompSci
May 26th, 2002, 04:24 PM
I got this working fine:
if (navigator.appName.indexOf("Netscape")!= -1)
{
/*if (navigator.appVersion.indexOf("4.72")!= -1
{*/
document.write("<multicol cols='4' gutter='20' width='800'");
document.write("<li><a href='MyCertifications.html'>Certifications</a>");
document.write("<li><a href='http://development.freeservers.com'>Progsharehouse.com</a>");
document.write("<li><a href='jobboards.html'>Job Board Links</a>");
document.write("<li><a href='http://www.unix.com/'>Unix board</a>");
document.write("<li><a href='affiliations.html'>Affiliations</a>");
document.write("<li><a href='ThanksTo.html'>Thanks To</a>");
document.write("</multicol>");
document.write("</menu>");
document.write("<br>");
/* }*/
}
What is wrong with the way I am testing appVersion? I tried nesting and with &&. I only have one Javascript book and it won't tell me.
(this post also up at my home page www.edwardtisdale.com)
websmith99
September 27th, 2002, 04:48 PM
All I did was change
if (navigator.appVersion.indexOf("4.72")!= -1
to
if (navigator.appVersion.indexOf("4.72")!= -1)
and it worked for me.
TrueLies
October 1st, 2002, 11:28 AM
navigator.appVersion.indexOf("4.72")
would test and match ONLY if it is EXACTLY 4.72
maybe you may want to consider:
if( parseInt(navigator.appVersion)<5 && parseInt(navigator.appVersion)>=4 ){
/*stuff*/
}
many would advice you to detect NN4 by:
if(document.layers)
it is correct as well, although at times it can fail (oh yes!) detecting Netscape 4 in some circumstances (a NN4 bug indeed, but it shows up rarely. I won't detail more now for this was not the original question)
ciao
websmith99
October 1st, 2002, 02:17 PM
More on the topic of browser detection-
For those who wish to support NN4+ and IE4+, it becomes neccessary sometimes to have efficient browser detection for those times when you run across the competing object models.
However, sometimes those object models are overlapping so some caution should be taken when doing the browser detection. For example, both NN6 & IE6 use document.getElementById, yet IE6 also uses document.all.
Therefore, you should check first for document.all, then check for document.getElementById. The other way around will cause unexpected errors. This example does browser detection so NN4, NN6, IE4+ can all check if the arrow keys or pageup, pagedown keys were pressed so special navigation can be done:
<head>
<script language="JavaScript1.2">
if (document.all) {
} else if (document.layers) {
document.captureEvents(Event.KEYPRESS);
document.onkeydown = getKeyCode;
} else if (document.getElementById) {
document.addEventListener("keyup",getKeyCode,true);
}
function getKeyCode(e) {
keyPressed = 0;
if (document.all) {
keyPressed = event.keyCode;
} else if (document.layers) {
// does not work on NN4 for windows platforms, only mac
// as the directional arrows and pageup, pagedown
// are not valid keyboard keys for this event in
// Netscape 4.x for windows http://tech.irt.org/articles/js195/
if (e.which == 11 || e.which == 28 || e.which == 30) {
goToPreviousPage(); // my defined function
} else if (e.which == 12 || e.which == 29 || e.which == 31) {
goToNextPage(); // my defined function
}
} else if (document.getElementById) {
keyPressed = e.keyCode;
}
if (keyPressed == 33 || keyPressed == 37 || keyPressed == 38) {
goToPreviousPage();
} else if (keyPressed == 34 || keyPressed == 39 || keyPressed == 40) {
goToNextPage();
}
}
</script>
</head>
<body onkeydown="getKeyCode()">
Also, if you support AOL, please note that AOL 5 and AOL 6 have a bug where the useragent string passed in the
http header for the first browser window does not contain “AOL”.
Because of this bug, you can not reliably use JavaScript browser detection
for the AOL browser, as the “navigator.userAgent” and “navigator.appName”
will return values identical to that of Internet Explorer. It should be noted
that if the original browser window of a user’s AOL session is closed, all
subsequent browser windows of that session will correctly include the
string “AOL” in the http header. AOL 7 does not have this bug.