Skip to content Skip to sidebar Skip to footer

Javascript Timer Page Up And Down Won't Go To Bottom Of Page

I have a timer script which scrolls up and down and repositions the page to the top every 10 seconds and back down every 5 seconds. My problem is I can't get it to scroll all the

Solution 1:

I think this is much simpler and achieves what you're looking for:

function starttime() {
    setTimeout('scrollDown()',5000);
}

function scrollDown() {
    window.scrollto(0, document.body.scrollHeight);
    setTimeout('scrollUp()',5000);
}

function scrollUp() {
    window.scrollto(0,0);
    setTimeout('scrollDown()',5000);
}

window.onload = starttime

Solution 2:

The reason your page wouldn't scroll all the way down is probably with your pixel value of 1200. This scrolls the page down 1200px, which may or may not be all the way. Heck, your page could be 10000px high or more. Try setting a limit that you can safely know you're page will never surpass, like 20000, and it should scroll all the way to the bottom. :D


Post a Comment for "Javascript Timer Page Up And Down Won't Go To Bottom Of Page"