javascript: detect scroll end
The accepted answer was fundamentally flawed, it has since been deleted. The correct answer is:
function scrolled(e) { if (myDiv.offsetHeight + myDiv.scrollTop >= myDiv.scrollHeight) { scrolledToBottom(e); }}
Tested this in Firefox, Chrome and Opera. It works.
I could not get either of the above answers to work so here is a third option that works for me! (This is used with jQuery)
if (($(window).innerHeight() + $(window).scrollTop()) >= $("body").height()) { //do stuff}
Hope this helps anyone!
OK Here is a Good And Proper Solution
You have a Div call with an id="myDiv"
so the function goes.
function GetScrollerEndPoint(){ var scrollHeight = $("#myDiv").prop('scrollHeight'); var divHeight = $("#myDiv").height(); var scrollerEndPoint = scrollHeight - divHeight; var divScrollerTop = $("#myDiv").scrollTop(); if(divScrollerTop === scrollerEndPoint) { //Your Code //The Div scroller has reached the bottom }}