Body is the body subnode In the DOM object, that is, the body tag. documentElement is the root node root of the entire node tree. For details, see this article. If you are interested, see the following differences:
Body is the body subnode In the DOM object, that isTag;
DocumentElement is the root node root of the entire node tree, that isTag;
In BackCompat mode, if no DTD is used:
The Code is as follows:
Document.doc umentElement. clientHeight = 0document. body. clientHeight = 618
In the standard mode of CSS1Compat, when using DTD:
The Code is as follows:
Document.doc umentElement. clientHeight = 618 document. body. clientHeight = 28 (indicating the height of the content)
Therefore, you must pay attention to the size of the browser. You can refer to the following code:
The Code is as follows:
If (document. compatMode = "BackCompat "){
CWidth = document. body. clientWidth;
CHeight = document. body. clientHeight;
SWidth = document. body. scrollWidth;
SHeight = document. body. scrollHeight;
SLeft = document. body. scrollLeft;
STop = document. body. scrollTop;
}
Else {// document. compatMode = "CSS1Compat"
CWidth = document.doc umentElement. clientWidth;
CHeight = document.doc umentElement. clientHeight;
SWidth = document.doc umentElement. scrollWidth;
SHeight = document.doc umentElement. scrollHeight;
SLeft = document.doc umentElement. scrollLeft = 0? Document. body. scrollLeft: document.doc umentElement. scrollLeft;
STop = document.doc umentElement. scrollTop = 0? Document. body. scrollTop: document.doc umentElement. scrollTop;
}