document.getElementById('mydiv').scrollHeight
...returns the range, and...
document.getElementById('mydiv').scrollTop
...returns the position of the top of the scroll handle in the range,
but that's not enough information because the scroll handle adds an
arbitrary amount of height. Is there a way to test for the height of
the scroll handle, or is there just a better way to test if the scroll
bar is at the bottom of the range?
Thanks.
You need the clientHeight property to complete the equation, but it
has nothing to do with the scrollbar dimensions.
var myDiv = document.getElementById("myElement"); //get the html
element
height = myDiv.scrollHeight; //total height of
div element
position = myDiv.scrollTop; //where the
scrollbar is positioned if overflowing...
scrollbar = myDiv.clientHeight; //the actual
height of scrollbar widget (the blue thingamajiggy)
//to check if the scrollbar is docked at the bottom
//do something like this...
if((height - position) == scrollbar){
alert('scrollbar is docked at the bottom');
}
-bseanvt
oops... made a mistake... need to add those vars together. here is the
code:
var container = document.getElementById("my_container");
height = container.clientHeight;
scroll = container.scrollHeight;
positon = container.scrollTop;
if((height + position) == scroll){
/* do something here like reposition scrollbar */
container.scrollTop = 123;
}