js gets the height and width of the screen

Web visible area width: document.body.clientWidth
Web visible area height: document.body.clientHeight
Web visible area width: document.body.offsetWidth (including the width of the border)
Web visible area height: document.body.offsetHeight (including the border Width) The
full text of the webpage body width: document.body.scrollWidth The
full text of the webpage body height: document.body.scrollHeight
The height of the
webpage being scrolled: document.body.scrollTop The left of the webpage being scrolled: document.body.scrollLeft
on the body part of the webpage : Window.screenTop
web page body part left: window.screenLeft
screen resolution height: window.screen.height
screen resolution width: window.screen.width
screen available work area height: window.screen.availHeight
screen available work area width : Window.screen.availWidth

HTML precise positioning: scrollLeft, scrollWidth, clientWidth, offsetWidth
scrollHeight: Get the scroll height of the object.
scrollLeft: set or get the distance between the left edge of the object and the leftmost end of the currently visible content in the window
scrollTop: set or get the distance between the topmost part of the object and the topmost part of the visible content in the window
scrollWidth: get the scroll width of the object
offsetHeight: Get the height of the object relative to the layout or the parent coordinate specified by the parent coordinate offsetParent property
offsetLeft: Get the calculated left position of the
object relative to the layout or the parent coordinate specified by the offsetParent property offsetTop: Get the object relative to the layout or the offsetTop property The calculated top position of the specified parent coordinates
event.clientX the horizontal coordinate
relative to the document event.clientY the vertical coordinate relative to the document
event.offsetX the horizontal coordinate
relative to the container event.offsetY the vertical coordinate relative to the container
document.documentElement.scrollTop Vertical scrolling The value
event.clientX+document.documentElement.scrollTop relative to the horizontal coordinate of the document + the amount of scrolling in the vertical direction

The differences between IE and FireFox are as follows:

IE6.0、FF1.06+:
clientWidth = width + padding
clientHeight = height + padding
offsetWidth = width + padding + border
offsetHeight = height + padding + border

IE5.0/5.5:
clientWidth = width - border
clientHeight = height - border
offsetWidth = width
offsetHeight = height

(It needs to be mentioned: the margin property in CSS has nothing to do with clientWidth, offsetWidth, clientHeight, and offsetHeight) The
width of the
visible area of ​​the
webpage : document.body.clientWidth The height of the visible area of ​​the webpage: document.body.clientHeight The width of the visible area of ​​the webpage: document.body .offsetWidth (including the width of the sideline) the
height of the visible area of ​​the webpage: document.body.offsetHeight (including the height of the sideline) the
width of the full text of the
webpage: document.body.scrollWidth the height of the full text of the
webpage : document.body.scrollHeight : Document.body.scrollTop
web page is scrolled to the left: document.body.scrollLeft
web page body part: window.screenTop
web page body part left: window.screenLeft
screen resolution height: window.screen.height
screen resolution width : Window.screen.width
available working area height of the
screen : window.screen.availHeight available working area width of the screen: window.screen.availWidth

Guess you like

Origin blog.csdn.net/weixin_43452467/article/details/113642699