make a page scroll down to its very end, every 5 seconds?

Update:

Sorry about the confusion.

What I'm trying to do is making a web page scroll down to its very end, every 5 seconds, how can I do that?

I tried repeat pressing the end key to get this happen, but I fails.

These were my attempts:

function pressEnd() {
    $('body').keypress({keyCode: 35});
}

setInterval(function () {
    pressEnd();
}, 5000);

And:

$('body').trigger('keydown', {which: 35});

And:

var event = $.Event('keydown', {keyCode: 35});
$('body').trigger(event);

Also tried to change the selector from body to document and window!

What am I missing?

Answers 1

  • Update

    This script will auto scroll down to the bottom of page every 5 sec with animation duration of 500 ms

    function scrollDown(el) {
        el.animate({
            scrollTop: el[0].scrollHeight
        }, 500, function() {
            scrollUp(el)
        });
    };
    
    
     $(document).ready(function() { 
    window.setInterval(function(){
      scrollDown($("html,body"));
    }, 5000);
    })
    

    SEE fiddle : http://jsfiddle.net/BDc6S/240/

    Previously

    Create a function to send end key and call it every 5 sec using jQuery window.setInterval(function(){})on $(document).ready(function() {}) like

    function myFunction() {
    var key35 = $.Event("keydown", { keyCode: 35 });
    $("body").trigger(key35);
    alert("end key pressed");
    }
    
    $(document).ready(function() { 
    window.setInterval(function(){
      myFunction();
    }, 5000);
    })
    

    SEE FIDDLE: https://jsfiddle.net/utp2sfm4/


Related Articles