javascript 现在 document.all 和 document.layers 已过时
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15854504/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
are document.all and document.layers obsolete now
提问by Paul
I am going through some (old?) native javascript and I encountered a separation of document.getElementById, document.all and document.layers.
我正在使用一些(旧的?)原生 javascript,我遇到了 document.getElementById、document.all 和 document.layers 的分离。
From what I know, document.all and document.layers are obsolete now, but I just wanted to make sure.
据我所知, document.all 和 document.layers 现在已经过时了,但我只是想确定一下。
回答by Guffa
Yes, they are obsolete.
是的,它们已经过时了。
The document.all
collection is specific to Internet Explorer. The document.layers
collection was specific to Netscape. Neither is in the standards.
该document.all
集合特定于 Internet Explorer。该document.layers
集合是特定于 Netscape 的。两者都不在标准中。
Today we use document.getElementById
instead.
今天我们用document.getElementById
代替。
另见:https: //developer.mozilla.org/en-US/docs/Mozilla_Web_Developer_FAQ#JavaScript_doesn.E2.80.99t_work.21_Why.3F
回答by ZER0
Yes, they are. They comes from a period where Internet Explorer 4 and Netscape 4.x were the main browsers: document.layers
was used by Netscape, and document.all
from IE. The first is definitely unused anymore, where I guess document.all
is still used for legacy in IEs.
对,他们是。它们来自 Internet Explorer 4 和 Netscape 4.x 是主要浏览器的时期:document.layers
由 Netscape 和document.all
IE 使用。第一个肯定不再使用了,我猜document.all
它仍然用于 IE 中的遗留。