Javascript obtains the size and position of a window (container). Many things are easy to confuse. Here we will give a brief description:
Attribute method description:
The horizontal coordinate of clientX relative to the document;
The vertical coordinate of clientY relative to the document;
Horizontal coordinates of offsetX relative to the container;
Vertical coordinate of offsetY relative to container;
ScrollWidth: get the scroll width of the object;
ScrollHeight: obtains the scroll height of an object;
ScrollLeft sets or obtains the distance between the left-side border of the object and the leftmost end of the currently visible content in the window;
ScrollTop sets or gets the distance between the top of the object and the top of the visible content in the window;
OffsetWidth: gets the width of the object relative to the layout or the parent coordinate specified by the parent coordinate offsetParent attribute;
OffsetHeight: gets the height of the object relative to the layout or the parent coordinate specified by the parent coordinate offsetParent attribute;
OffsetLeft obtains the left position of the object relative to the layout or the parent coordinate specified by the offsetParent attribute;
OffsetTop obtains the top position of the object relative to the layout or the parent coordinate specified by the offsetTop attribute.
How to obtain screen and window size using Javascript:
Screen Resolution height: window. screen. height;
Screen Resolution width: window. screen. width;
Available screen workspace height (excluding the taskbar): window. screen. availHeight;
Available workspace width (excluding the taskbar): window. screen. availWidth;
Visible area width (excluding the scroll bar and border): document. body. clientWidth;
The visible area of the webpage is high (excluding the scroll bar and border): document. body. clientHeight;
Visible area width of the webpage (including the scroll bar and border): document. body. offsetWidth;
The visible area of the webpage is high (including the scroll bar and border): document. body. offsetHeight;
Webpage body width: document. body. scrollWidth;
Webpage body height: document. body. scrollHeight;
The height of the page to be rolled: document. body. scrollTop;
Left of the webpage to be rolled: document. body. scrollLeft;
On the webpage body (the leftmost distance from the webpage body to the left edge of the screen): window. screenTop;
The left part of the webpage body (the distance between the top part of the webpage body and the edge of the screen): window. screenLeft.
Note: Sometimes the value cannot be obtained because the document type is added to the html file header.:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">,
In this case. body. scrollTop and document. body. changed scrollLeft to document.doc umentElement. scrollTop and document.doc umentElement. scrollLeft, document. body. clientWidth and document. body. change clientHeight to document.documentelement.clientwidthand document.doc umentElement. clientHeight
Of course there are still omissions or unclear points. You can add, discuss, or Baidu to make progress together! Ye ~