minil minil - 8 days ago 5
HTML Question

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)?

Answer

If I scroll down 5px in this window, the window's scrollTop value is 5. If I scroll right 10px in a scrollable div, the div's scrollLeft value is 10.

When I scroll to the top left corner of this window, both its scrollTop and scrollLeft values are 0.