Friday, July 23, 2010
This code snippet provides a JavaScript function to scroll a HTML page programatically to the bottom on page load.

Make the browser height smaller to observe the scrolling effect.

The javascript. Store it in your JavaScript file, here "testme.js".

window.onload=toBottom;

function toBottom()
{
alert("Scrolling to bottom ...");
window.scrollTo(0, document.body.scrollHeight);
}

The test html code.

<html>
    <head>
        <script src="testme.js" language="javascript" type="text/javascript"></script>
    </head>
    <body>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>
        Some big text<br/>        
  </body>
</html>

Contact Form

Name

Email *

Message *

Back to Top