Detect when Scroll reaches the BOTTOM of the page [ without jQuery ]

javascript, scroll

Solution

document.addEventListener('scroll', function (event) {
    if (document.body.scrollHeight == 
        document.body.scrollTop +        
        window.innerHeight) {
        alert("Bottom!");
    }
});

JSFiddle here: http://jsfiddle.net/cSer6/

Problem

I want to alert something when the scroll reaches the BOTTOM of the page, like this: ``` $(function(){ $(document).scroll(function() { if($(document).scrollTop() == 0) alert("top"); }) }) ``` But without jQuery, and alert when reaches the Bottom.

Original source

Related problems