programatically to the bottom on page load. Make the browser height
smaller to observe the scrolling effect.
The javascript.
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>
very cool & good js tip, thank you very much for sharing.
ReplyDeleteHow do you control the speed that this thing scrolls so you can make it smooth, yet not take forever if the page is really long? And can you think of a way to make the scrolling speed increase as the page scrolls?
ReplyDelete