In the construction of the page will often need to get some of the width of the page information, such as the implementation of lazy loading the image needs to get the height of the visible area of the page and the height of the scrolled area, to determine whether the picture is visible to determine the time to load the picture,
Take a moment to sort out the API for page width and height information
Continuous finishing ...
In IE:
Document.body.clientWidth ==> Body Object width
Document.body.clientHeight ==> Body Object Height
Document.documentElement.clientWidth ==> Visible Area width
Document.documentElement.clientHeight ==> Visible Area height
In Firefox:
Document.body.clientWidth ==> Body Object width
Document.body.clientHeight ==> Body Object Height
Document.documentElement.clientWidth ==> Visible Area width
Document.documentElement.clientHeight ==> Visible Area height
In Opera:
Document.body.clientWidth ==> Visible Area width
Document.body.clientHeight ==> Visible Area height
Document.documentElement.clientWidth ==> The width of the page object (that is, the body object width plus the margin width)
Document.documentElement.clientHeight ==> Page Object height (i.e. body object height plus margin height)
And if there is no standard to define the
IE is:
Document.documentElement.clientWidth ==> 0
Document.documentElement.clientHeight ==> 0
Firefox is:
Document.documentElement.clientWidth ==> Page object width (i.e. body object width plus margin) Document.documentElement.clientHeight = = > Page object height (i.e. body object height plus margin)
Opera is:
Document.documentElement.clientWidth ==> Page object width (i.e. body object width plus margin) Document.documentElement.clientHeight = = > Page object height (i.e. body object height plus margin)
Really a troublesome thing, in fact, in terms of development, rather fewer objects and methods, do not use the latest standards to facilitate many AH.
width of visible area of Web page:
Document.body.clientWidth
Web page visible Area High:
Document.body.clientHeight
width of visible area of Web page:
Document.body.offsetWidth (including the width of the edge)
Web page visible Area High:
Document.body.offsetHeight (including the width of the edge)
Page body Full text width:
Document.body.scrollWidth
Page body Full text High:
Document.body.scrollHeight
The page is rolled away High:
Document.body.scrollTop
Window.pageyoffset
Webpage is rolled away left:
Document.body.scrollLeft
Window.pagexoffset
On the body part of the webpage:
Window.screentop
Page body part left:
Window.screenleft
High screen resolution:
Window.screen.height
Width of screen resolution:
Window.screen.width
Screen usable workspace height:
Window.screen.availHeight
Screen Usable workspace width:
Window.screen.availWidth
JavaScript common get page width high information API