Click to See Complete Forum and Search --> : Netscape 7 check


florida
05-27-2003, 05:18 AM
I have been working with Netscape 4 but now have ALSO have Netscape 7.

Please advise how I can check for Netscape 7:

ns4=(document.layers);
if(ns4)
{
//do Netscape 4 stuff here
}
else if(NETSCAPE 7 HERE CHECK)
{
//do Netscape 7 stuff here
}
else
{
//DO IE STUFF HERE
}

AdamGundry
05-27-2003, 05:22 AM
It's better to test if the browser supports the feature you are trying to use, to be future-proof. For example, if you want to use document.getElementById:

if (document.getElementById) {
// Method is available
} else {
// Not available
}

Adam

florida
05-27-2003, 05:57 AM
Thanks for the quick response!

But I need to distinguish between Netscape 4 and Netscape 7 and IE.

Isnt 'document.getElementById' used by both Netscape 7 and IE? If so how can I distinguish if I distinguish between the two?


ns4=(document.layers);
if(ns4)
{
//do Netscape 4 stuff here
}
else if(document.getElementById)
{
//do Netscape 7 stuff here
}
else if(IE CHECK HERE)
{
//DO IE STUFF HERE
}

Charles
05-27-2003, 06:15 AM
Originally posted by florida
But I need to distinguish between Netscape 4 and Netscape 7 and IE. Do you? Mr. Gundry is quite right, you shouldn't have to except in very limited circumstances. But if you must, or if your head to too hard for your own good, then see http://devedge.netscape.com/library/manuals/2000/javascript/1.3/reference/nav.html.

khalidali63
05-27-2003, 07:49 AM
if(document.layers){
//below and ns4.7
}else if (!document.all && document.getELementById){
//NS6+ and up
}else if(document.all && document.documentElement){
//IE6 an above
}else if(document.all && !document.documentElement){
//IE below and 5.5
}

Hope this helps

florida
05-28-2003, 06:14 AM
Thanks!