Automatically scroll to bottom as the page loads

LPChip

I have a php script that shows a log of its actions as the script proceeds. The log is getting quite long, up to the point where it will echo its information past the bottom of the page, adding a scrollbar to the page.

If I want to see the rest of the log, I have to manually scroll down. I can make the page go to say... process.php#bottom but I can't just insert a <a name="bottom" /> after each log item and expect the browser to keep jumping to the bottom, can I?

Is there a a javascript function, or other easy method, that will automatically scroll the page to the bottom as soon as this isn't the case?

I don't mind if it overrides the user's ability to scroll, as the script will redirect back to the main script after 3 seconds at the end anyway.

I do not necessarily need a full script, if you just have pointers, but those that provide a full working script will obviously get their answer accepted over those that just give pointers.

If you don't have an idea of what I mean by the log, you can use the following script to simulate what my script does:

<?php
for( $iLineNumber=0 ; $iLineNumber <100 ; $iLineNumber++ )
{
    echo $iLineNumber , ' - This is a test. <br />';
    sleep(1);
}
?>

Basically, as the script loads and sleeps every second, when it hit the bottom of the page, it should automatically scroll down every second.

Azazi

This works:

<script>

    setTimeout(printSomething, 1000);

    function printSomething(){
        for(var i=0; i<10; i++){
            document.write("Hello World\n");
            document.write("<br>");
        }
        window.scrollTo(0,document.body.scrollHeight);
        setTimeout(printSomething, 1000);
    }
</script>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Scroll Automatically to the Bottom of the Page

From Dev

Scroll automatically to the bottom page - speed control

From Dev

How to automatically scroll the window to some height as the page loads

From Dev

Infinitely scroll to the bottom of the page

From Dev

Scroll to near the bottom of page

From Dev

scroll the a growing page to the bottom

From Dev

Scroll bar in page bottom

From Dev

Scroll to near the bottom of page

From Dev

How to automatically scroll to the bottom in AngularJS?

From Dev

How to scroll the window automatically when mouse moves bottom of the page using jquery

From Dev

JS for smooth scroll to the bottom of the page

From Dev

$mdtoast position bottom of page on scroll

From Dev

JS for smooth scroll to the bottom of the page

From Dev

$mdtoast position bottom of page on scroll

From Dev

Scroll to the Bottom of the Page after postBack

From Dev

scroll to bottom on page load but will allow to scroll on top

From Dev

scroll to bottom on page load but will allow to scroll on top

From Dev

Endless pagination loads entire page contents on scroll

From Dev

Maintaining scroll position between page loads with JavaScript

From Dev

Scroll function executes also when page loads

From Dev

ng-repeat render and automatically scroll to bottom

From Dev

On Scroll fires automatically on page refresh

From Dev

Laravel - redirect to page and scroll to the bottom of the page

From Dev

Laravel - redirect to page and scroll to the bottom of the page

From Dev

how to scroll the page to bottom whenever the page load?

From Dev

OnClick loads new HTML doc and should scroll to the bottom of it

From Dev

How to scroll to automatically scroll to the bottom of an editable div onload

From Dev

jquery one page scroll start at the bottom

From Dev

Detect if scroll has touched bottom of page

Related Related

  1. 1

    Scroll Automatically to the Bottom of the Page

  2. 2

    Scroll automatically to the bottom page - speed control

  3. 3

    How to automatically scroll the window to some height as the page loads

  4. 4

    Infinitely scroll to the bottom of the page

  5. 5

    Scroll to near the bottom of page

  6. 6

    scroll the a growing page to the bottom

  7. 7

    Scroll bar in page bottom

  8. 8

    Scroll to near the bottom of page

  9. 9

    How to automatically scroll to the bottom in AngularJS?

  10. 10

    How to scroll the window automatically when mouse moves bottom of the page using jquery

  11. 11

    JS for smooth scroll to the bottom of the page

  12. 12

    $mdtoast position bottom of page on scroll

  13. 13

    JS for smooth scroll to the bottom of the page

  14. 14

    $mdtoast position bottom of page on scroll

  15. 15

    Scroll to the Bottom of the Page after postBack

  16. 16

    scroll to bottom on page load but will allow to scroll on top

  17. 17

    scroll to bottom on page load but will allow to scroll on top

  18. 18

    Endless pagination loads entire page contents on scroll

  19. 19

    Maintaining scroll position between page loads with JavaScript

  20. 20

    Scroll function executes also when page loads

  21. 21

    ng-repeat render and automatically scroll to bottom

  22. 22

    On Scroll fires automatically on page refresh

  23. 23

    Laravel - redirect to page and scroll to the bottom of the page

  24. 24

    Laravel - redirect to page and scroll to the bottom of the page

  25. 25

    how to scroll the page to bottom whenever the page load?

  26. 26

    OnClick loads new HTML doc and should scroll to the bottom of it

  27. 27

    How to scroll to automatically scroll to the bottom of an editable div onload

  28. 28

    jquery one page scroll start at the bottom

  29. 29

    Detect if scroll has touched bottom of page

HotTag

Archive