Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can someone canonically differentiate between scrollTop and scrollHeight?

For example,

function fnCheckScroll(){        var iNewHeight = oDiv.scrollHeight;     var iscrolTop = oDiv.scrollTop;      alert("The value of the scrollHeight property is: "  + iNewHeight + "px");      alert("The value of the scrollTop property is: " + iscrolTop + "px");         }  <div id="oDiv" style="overflow: scroll; height= 100px; width= 250px; text-align: left"> Hello<br> </div> 

In IE 8, the value of scrollTop is always: 0 - returns 0 for scrollTop (even after scrolling)?

like image 849
minil Avatar asked May 30 '10 19:05

minil


People also ask

What is the difference between scrollHeight and clientHeight?

clientHeight: It returns the height of an HTML element including padding in pixels but does not include margin, border and scrollbar height. scrollHeight: It returns the height of the content enclosed in an html element including padding but not margin, border and scroll bar.

What is scrollTop and scrollHeight?

In summary, scrollTop is how much it's currently scrolled, and scrollHeight is the total height, including content scrolled out of view.

Is scrollTop deprecated?

scrollTop is deprecated in strict mode.

What does scrollTop mean?

An element's scrollTop value is a measurement of the distance from the element's top to its topmost visible content. When an element's content does not generate a vertical scrollbar, then its scrollTop value is 0 .


2 Answers

enter image description here

Ref: scrollTop, scrollHeight, clientHeight

like image 119
Tho Avatar answered Oct 05 '22 20:10

Tho


See the MDC articles, scrollTop and scrollHeight. In summary, scrollTop is how much it's currently scrolled, and scrollHeight is the total height, including content scrolled out of view.

like image 45
Matthew Flaschen Avatar answered Oct 05 '22 19:10

Matthew Flaschen