In my local test: it can be used in IE, FireFox, and Opera.
Document. body. clientWidth
Document. body. clientHeight can be obtained, which is very simple and convenient.
In the company project, Opera still uses
Document. body. clientWidth
Document. body. clientHeight
However, IE and FireFox use
Document.doc umentElement. clientWidth
Document.doc umentElement. clientHeight
It turned out to be W3C standards in the end of the http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
If this line is added to the page
In IE: document. body. clientWidth => BODY object width
Document. body. clientHeight ==> BODY object height
Document.doc umentElement. clientWidth ==> visible area width
Document.doc umentElement. clientHeight => visible area height
In FireFox: document. body. clientWidth => BODY object width
Document. body. clientHeight ==> BODY object height
Document.doc umentElement. clientWidth ==> visible area width
Document.doc umentElement. clientHeight ==> visible area height?
In Opera: document. body. clientWidth => visible area width
Document. body. clientHeight ==> visible area height
Document.doc umentElement. clientWidth ==> Page Object width (that is, adding the bodyobject width to the marginwidth) document.doc umentElement. clientHeight ==> Page Object height (that is, the BODY object height plus the Margin height)
If W3C standards are not defined,
IE is: document.doc umentElement. clientWidth => 0
Document.doc umentElement. clientHeight => 0
FireFox: document.doc umentElement. clientWidth => Page Object width (that is, the width of the BODY object plus the Margin width)
Document.doc umentElement. clientHeight ==> Page Object height (that is, the height of the BODY object plus the Margin height)
Opera: document.doc umentElement. clientWidth => Page Object width (that is, the width of the BODY object plus the Margin width)
Document.doc umentElement. clientHeight ==> Page Object height (that is, the height of the BODY object plus the Margin height)
From the developer's point of view, it is much easier to use fewer objects and methods than to use the latest standards.