First you will need to check if you are at the bottom of the page or not. Using Gaby's answer to Definition while scrolling to the bottom of the page using Javascript :
function scrollbarAtBottom() {
var totalHeight, currentScroll, visibleHeight;
if (document.documentElement.scrollTop)
currentScroll = document.documentElement.scrollTop;
else
currentScroll = document.body.scrollTop;
totalHeight = document.body.offsetHeight;
visibleHeight = document.documentElement.clientHeight;
if (totalHeight <= currentScroll + visibleHeight)
return true;
else
return false;
}
You can then manipulate the DOM and scroll to the bottom if the value returned scrollbarAtBottomwas true:
var atBottom = scrollbarAtBottom();
if (atBottom)
if (document.documentElement.scrollTop)
document.documentElement.scrollTop = document.documentElement.clientHeight;
else
document.body.scrollTop = document.body.clientHeight;
source
share