I have this function, which in itself works fine, however it scrolls down whenever i scroll up which is not intended.
I want it to run the function ONLY if the scrollbar of the div (overflow) is at the bottom, which makes it possible to scroll up without it scrolling back down preventing the view of older messages.
function opdaterPost(til, fra){
$('#beskeder_vis').load('calls/opdater_post.php?til=' + til + '&fra=' + fra);
$("#beskeder_vis").animate({ scrollTop: $("#beskeder_vis").prop("scrollHeight") }, 1500);
}
Here’s a jsfiddle showing the chat box
http://jsfiddle.net/w989Y/
You check if the div is scrolled to the bottom by: