ccc

JQuery Scroll: Detectar si el usuario ha llegado al final de la página con el scroll

function getDocHeight() {
    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!");
    }
});

No hay comentarios:

Publicar un comentario