Reputation: 101
Can anybody tell me the difference between these two JavaScript commands?
Also what is the compatibility of these two across major browsers? I know documentElement
is compatible with most browsers.
Thanks
Upvotes: 7
Views: 1943
Reputation: 91686
document.documentElement
is a reference to the root element of the document, usually the <html>
tag.
document.all
is a collection type, containing an enumeration of all the children tags within the document. It's IE specific and should be avoided for cross-browser scripts.
document.documentElement
is DOM Level 2, so should work in pretty much any major browser these days.
Upvotes: 7
Reputation: 662
document.all
is a proprietary Microsoft extension to the W3C-standard.
It's an old function and should not be used anymore!
rfc document.all vs. document.getElementById
Upvotes: 6