Document.compatmode is used to determine the rendering method used by the current browser.
Backcompat: Standard compatibility mode is off.
Css1compat: Standard compatibility mode is turned on.
When Document.compatmode equals Backcompat, the width of the browser client area is document.body.clientWidth;
When Document.compatmode equals Css1compat, the browser client area width is document.documentElement.clientWidth.
Compatible with the code that gets the width of the page client area, the width of the scroll bar, the left and top of the scrollbar:
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.documentElement.clientWidth;
Cheight = Document.documentElement.clientHeight;
Swidth = Document.documentElement.scrollWidth;
Sheight = Document.documentElement.scrollHeight;
Sleft = Document.documentElement.scrollLeft = = 0? Document.body.scrollLeft:document.documentElement.scrollLeft;
STop = Document.documentElement.scrollTop = = 0? Document.body.scrollTop:document.documentElement.scrollTop;
}
Browser rendering method, and compatible to get Web page width and scroll bar