11

私はいくつかの (古い?) ネイティブ JavaScript を使用していますが、document.getElementById、document.all、および document.layers の分離に遭遇しました。

私の知る限り、document.all と document.layers は廃止されましたが、確認したかっただけです。

4

2 に答える 2

14

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.

Today we use document.getElementById instead.

See also: https://developer.mozilla.org/en-US/docs/Mozilla_Web_Developer_FAQ#JavaScript_doesn.E2.80.99t_work.21_Why.3F

于 2013-04-06T18:35:20.433 に答える
2

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.

于 2013-04-06T18:32:55.227 に答える