The way to get the height and width of DOM elements in JavaScript is as follows:
Web page Visible area width: document.body.clientWidth
Web page Visible Area height: document.body.clientHeight
Web page Visible Area width: document.body.offsetWidth (including edge width)
Web page Visible Area High: document.body.offsetHeight (including edge height)
Page body Full text width: document.body.scrollWidth
Page body Full text High: Document.body.scrollHeight
Page is rolled away High: document.body.scrollTop
Webpage is rolled away left: document.body.scrollLeft
The width height of the corresponding DOM element has the following several common:
The actual height of the element: document.getElementById ("div"). offsetheight
The actual width of the element: document.getElementById ("div"). offsetwidth
The distance from the left edge of the element's actual distance: document.getElementById ("div"). offsetleft
The distance from the upper boundary of the element's actual distance: document.getElementById ("div"). OffsetTop
Get DOM element height and width in javascript