By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,510 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,510 IT Pros & Developers. It's quick & easy.

document.all vs. document.layers

P: n/a
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;

Dec 24 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
yawnmoth wrote:
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.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Dec 24 '05 #2

P: n/a
On 24/12/2005 09:16, David Dorward wrote:
yawnmoth wrote:
As I understand it, document.layers only works in Netscape 4+


No, it only works in Netscape 4.x.


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.
Dec 24 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.