js on scroll to bottom code example

Example 1: js scroll to bottom

window.scrollTo(0,document.body.scrollHeight);

Example 2: javascript reach bottom of page

function getDocHeight() {	// $(document).height() value depends on browser
    var D = document;
    return Math.max(
        D.body.scrollHeight, D.documentElement.scrollHeight,
        D.body.offsetHeight, D.documentElement.offsetHeight,
        D.body.clientHeight, D.documentElement.clientHeight
    );
}
$(window).scroll(function() {
       if($(window).scrollTop() + $(window).height() == getDocHeight()) {
           alert("bottom!");
       }
});