Connecting Tech Pros Worldwide Help | Site Map

document.all vs. document.layers

yawnmoth
Guest
 
Posts: n/a
#1: Dec 24 '05
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;

David Dorward
Guest
 
Posts: n/a
#2: Dec 24 '05

re: document.all vs. document.layers


yawnmoth wrote:
[color=blue]
> As I understand it, document.layers only works in Netscape 4+[/color]

No, it only works in Netscape 4.x. Netscape 6 onwards do not support it.
[color=blue]
> (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?[/color]

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).
[color=blue]
> Also, what about document.getElementById?[/color]

This is the standard.
[color=blue]
> When did Internet Explorer start supporting that and when did Netscape
> start supporting that?[/color]

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.
[color=blue]
> I ask because I'm wondering how necessary doing something similar to
> the following is[/color]

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.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Michael Winter
Guest
 
Posts: n/a
#3: Dec 24 '05

re: document.all vs. document.layers


On 24/12/2005 09:16, David Dorward wrote:
[color=blue]
> yawnmoth wrote:
>[color=green]
>> As I understand it, document.layers only works in Netscape 4+[/color]
>
> No, it only works in Netscape 4.x.[/color]

A minor note: not only NN4. There are one or two other browsers that
implement it. OmniWeb, for example. There's a post in the archives
somewhere...

<http://groups.google.co.uk/group/comp.lang.javascript/browse_frm/thread/ab32477a92514e24/a64d489104046c6f#a64d489104046c6f>

[snip]

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Closed Thread


Similar JavaScript / Ajax / DHTML bytes