简体   繁体   English

document.documentElement vs document.all

[英]document.documentElement vs document.all

Can anybody tell me the difference between these two JavaScript commands? 谁能告诉我这两个JavaScript命令之间的区别?
Also what is the compatibility of these two across major browsers? 这两个主要浏览器的兼容性是什么? I know documentElement is compatible with most browsers. 我知道documentElement与大多数浏览器兼容。

Thanks 谢谢

document.documentElement is a reference to the root element of the document, usually the <html> tag. document.documentElement是对文档根元素的引用,通常是<html>标记。

document.all is a collection type, containing an enumeration of all the children tags within the document. document.all是一个集合类型,包含document.all中所有子标记的枚举。 It's IE specific and should be avoided for cross-browser scripts. 它是IE特定的,应该避免跨浏览器脚本。

document.documentElement is DOM Level 2, so should work in pretty much any major browser these days. document.documentElement是DOM Level 2,所以现在几乎可以在任何主流浏览器中使用。

document.all is a proprietary Microsoft extension to the W3C-standard. document.all是W3C标准的专有Microsoft扩展。
It's an old function and should not be used anymore! 这是一个旧功能,不应再使用了!

rfc document.all vs. document.getElementById rfc document.all与document.getElementById

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM