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
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
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.
document.all
is a proprietary Microsoft extension to the W3C-standard.
It's an old function and should not be used anymore!