Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1296 How can I continually scroll through a document, restarting at the top once the bottom has been reached?

irt.org | Knowledge Base | JavaScript | Scroll | Q1296 [ previous next ]

Q1296 How can I continually scroll through a document, restarting at the top once the bottom has been reached?

Try:

<html>

<head>
<script language="JavaScript"><!--
var myHeight;
var myPosition = 0;

function size() {
    if (document.layers)   myHeight = document.dummy.document.height;
    else if (document.all) myHeight = document.myLayer.style.height;
    if (document.layers || document.all) docScroll(); 
}

function docScroll() {
    if (myPosition < myHeight) myPosition += 100; else myPosition = 0;
    window.scroll(0,myPosition);
    setTimeout('docScroll()',500);
}
//--></script>
</head>

<body bgcolor="#ffffff" onLoad="size()"><div name="dummy" style="position:absolute">

<p>
Start...
</p>

0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>
0<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>9<br>

<p>
...end
</p>

</div></body>

</html>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.