HTML and CSS Reference
EXPLANATION ( CONTINUED )
A variable called timeout is declared. It will hold the value returned from the set-
A function called startScroll() is defined. It will start the image scrolling from the
left of the screen to the right. If the scrolling is stopped before it reaches the end,
this function will start scrolling where it left off.
If the value of the variable pixelpos is less than the width of the window, keep go-
Add one to the pixel position.
The scrollTo() method takes two arguments, the horizontal pixel position and the
vertical pixel position. With vertical pixel position of 0, the image will move hor-
izontally over one pixel to the right.
Set the timeout to 20 milliseconds: scroll the image to the right 50 times per min-
A function called scrollAgain() is defined.
Scrolling starts again.
Stops the scrolling by clearing or turning off the timer.
This function closes the window.
Three buttons will be displayed. A function to start, stop, or restart the scrolling
will be called depending on which button the user clicks.
If the user clicks this link, the window with the image will be closed. See Figures
10.22 and 10.23.
Figure 10.22 The new window on the left has a scene that will scroll by slowly; it
can be stopped, and then restarted.