JavaScript element objects have the main attributes of the scroll family:
ScrollTop: (The height of the head being rolled away by the scroll bar)
ScrollLeft: (left-hand distance curled by scroll bar)
ScrollWidth (Content actual width: width+padding+ out of box width)
Scorllheight (actual height of the content: height+padding+ exceeds the height of the box)
Scroll can be found by the properties ScrollTop and ScrollLeft of the element object.
However, the entire browser's scroll bar is a compatibility issue with the document's ScrollBar element attribution.
IE678 and other browsers think that the entire document object belongs to the Document.documentelement element, which is HTML.
DTD <! not declared DOCTYPE Html> 's browser thinks the document object belongs to the Document.body element.
So just find the right element to achieve browser compatibility. if (Document.compatmode==css1compat) means that the document.documentelement element is supported, else means that the document.body element is supported.
The latest browsers ie9+ and other browsers believe that the entire document belongs to the Window object and can be obtained through window.pagexoffset and Window.pageyoffset, or through Window.scrollto (x, y) Slide the browser scroll bar to the specified X, y
Encapsulating the scroll function
1 functionScroll (element, Vals) {2 if(element = =NULL) {3 return;4 }5 if(Vals = =NULL) {6 7 return {8 Left:element.scrollLeft,9 Top:element.scrollTopTen } One A}Else { -Element.scrolltop =Vals.top; -Element.scrollleft =Vals.left; the } -}
Scroll
JavaScript Four family of the scroll family