This article is mainly about JS and jquery get page size, scroll bar position, element location sample code is introduced. Need friends can come to the reference, I hope to help you.
JS and jquery get page size, scroll bar position, element position code as follows://page position and window size function getpagesize () {var scrw, scrh; if window . Innerheight && Window.scrollmaxy) { //Mozilla SCRW = window.innerwidth + windows . Scrollmaxx; SCRH = window.innerheight + window.scrollmaxy; } else if (Document.body.scrollHeight > Docume Nt.body.offsetHeight) { //all but IE Mac SCRW = document.body.scrollWidth; SCRH = document.body.scrollheight; } else if (document.body) {//IE Mac SCRW = Document.body.offsetWi Dth SCRH = document.body.offsetHeight; } var winw, winh; if (window.innerheight) {/All except IE WINW = window.innerwidth;  ; Winh = window.innerheight; } else if (document.documentelement && document.documentElement.clientHeight) { //IE 6 Strict Mode WINW = document.documentelement.cLientwidth; Winh = document.documentelement.clientheight; } else if (document.body) {//other WINW = Document.body.clientWidth; Winh = document.body.clientheight; } //for small pages and total size less then the Vie wport var Pagew = (SCRW<WINW)? winw:scrw; var Pageh = (Scrh<winh)? WINH:SCRH; Return {Pagew:pagew, Pageh:pageh, WINW:WINW, Winh:winh}; }; //scroll bar position function Getpagescroll () { var x, y; if (window.pageyoffset) { //all except IE y = window.pageyoffset; x = window.pagexoffset; } else if (Document.documentelement && Document.documentElement.scrollTop) { //IE 6 Strict y = Document.documentElement.scroll Top; x = document.documentelement.scrollleft; } else if (document.body) { //all other IE   ; y = Document.bodY.scrolltop; x = Document.body.scrollLeft; } return {x:x, y:y}; } jquery Get the height of the browser display area: $ (window). Height (); Gets the width of the browser display area: $ (window). Width (); get page File Height: $ (document). Height (); Gets the document width of the page: $ (document). width (); Get the vertical height of the scroll bar to the top: $ (document). ScrollTop (); Gets the vertical width of the scroll bar to the left: $ (document). ScrollLeft (); Calculating the element position and offset Offset method is a useful way to return the offset information for the first element in the wrapper set. By default, the offset information for the body is relative. The result contains top and left two properties. Offset (options, results) Options.relativeto Specifies the ancestor element relative to the calculated offset position. This element should be relative or absolute positioned. The omission is relative to the body. Options.scroll Whether the scroll bar is counted, the default true options.padding whether the padding is counted, the default false options.margin whether the margin meter Included, the default true options.border whether the border is counted, default true