Can someone canonically differentiate between scrollTop and scrollHeight?

后端 未结 4 1968
花落未央
花落未央 2020-12-23 14:17

For example,

function fnCheckScroll(){   
    var iNewHeight = oDiv.scrollHeight;
    var iscrolTop = oDiv.scrollTop; 
    alert(\"The value of the scrollHei         


        
相关标签:
4条回答
  • 2020-12-23 14:23

    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.

    0 讨论(0)
  • 2020-12-23 14:28

    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.

    0 讨论(0)
  • 2020-12-23 14:39

    In Safari 6.0.1 the scrollHeight gives the height of the control and not the total height including content scrolled out of view. So it cannot be used to find the total height required to show without a scroll bar.

    0 讨论(0)
  • 2020-12-23 14:41

    Please see the following picture:

    Ref: scrollTop, scrollHeight, clientHeight

    0 讨论(0)
提交回复
热议问题