document.all vs. document.layers

Y

yawnmoth

As I understand it, document.layers only works in Netscape 4+ (ie. it
doesn't work in any version of Internet Explorer), while document.all
only works in Internet Explorer 4+ (ie. it doesn't work in any version
of Netscape). Is that correct?

Also, what about document.getElementById? When did Internet Explorer
start supporting that and when did Netscape start supporting that?

I ask because I'm wondering how necessary doing something similar to
the following is:

if(document.getElementById)
obj = document.getElementById(id);
else if(document.all)
obj = document.all[id];
else if(document.layers)
obj = document.layers[id];
else
return 1;
 
D

David Dorward

yawnmoth said:
As I understand it, document.layers only works in Netscape 4+

No, it only works in Netscape 4.x. Netscape 6 onwards do not support it.
(ie. it doesn't work in any version of Internet Explorer), while
document.all only works in Internet Explorer 4+ (ie. it doesn't work in
any version of Netscape). Is that correct?

No. document.all is supported by quite a lot of things, but most browsers
claim that they don't when you test for it (on the principles of (a) if you
test for it then you are hopefully also testing for the standard DOM and
(b) many people test for it and then assume the browser is IE).
Also, what about document.getElementById?

This is the standard.
When did Internet Explorer start supporting that and when did Netscape
start supporting that?

Versions 5 and 6 respectively IIRC.

There is more to the WWW then IE and NS though, Netscape is not a very
common browser these days. There is also Firefox, Opera, Konqueror, Safari,
and so on.
I ask because I'm wondering how necessary doing something similar to
the following is

Depends on how far back you want to support. Personally I find that sticking
to the standard DOM is enough and older browsers can get the fallback code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top