You are here: irt.org | FAQ | JavaScript | Scroll | Q876 [ previous next ]
It can't be done without knowing roughly how long the document is in pixels:
<html> <head><script language="JavaScript"><!-- function myHeight() { if (document.all) return document.body.offsetHeight; else if (document.layers) return document.body.document.height; else return 2000; // approx height (adjust as necessary) } function myScroll() { documentYposition += scrollAmount; window.scroll(0,documentYposition); if (documentYposition > documentLength) documentYposition = 0; setTimeout('myScroll()',scrollInterval); } function start() { documentLength = myHeight(); myScroll(); } var documentLength; var scrollAmount = 100; // scroll by 100 pixels each time var scrollInterval = 1000; // number of milliseconds between scrolls var documentYposition = 0; //--></script> </head> <body onLoad="start()"> <ilayer id="body"> Place page contents in here </ilayer> </body> </html>