HTML and CSS Reference
In-Depth Information
EXPLANATION ( CONTINUED )
7
A variable called timeout is declared. It will hold the value returned from the set-
Timeout() method.
8
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.
9
If the value of the variable pixelpos is less than the width of the window, keep go-
ing.
10
Add one to the pixel position.
11
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.
12
Set the timeout to 20 milliseconds: scroll the image to the right 50 times per min-
ute.
13
A function called scrollAgain() is defined.
14
Scrolling starts again.
15
Stops the scrolling by clearing or turning off the timer.
16
This function closes the window.
17
Three buttons will be displayed. A function to start, stop, or restart the scrolling
will be called depending on which button the user clicks.
18
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.
 
Search WWH ::




Custom Search