Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Scroll | Q1296 [ previous next ]

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>

©2018 Martin Webb