HTML and CSS Reference
In-Depth Information
EXAMPLE 10.12 ( CONTINUED )
4 <body onLoad = "startup()">
<h3>
Get Dizzy. Watch the title bar and the status bar!!
</h3>
<image src="christmasscene.bmp">
</body>
</html>
EXPLANATION
1
This is the same program as Example 10.11 using the setInterval() method for set-
ting a timer. The function called startup() contains the code to start the scrolling.
2
The setInterval() method is a window method and is executed and calls scroller() at
intervals of 500 milliseconds (.5 seconds), and will continue to do so until the win-
dow is exited or the clearInterval() method is called. In Example 10.11 we used set-
Timeout() instead of setInterval() .
3
This is the scroller() f unction that creates the text in both the title bar and the sta-
tus bar. It is executed at .5 second intervals.
4
When the page has finished loading, the onLoad event handler will call startup() .
Figure 10.21 The string “ Only 19 shopping days left until Christmas! ” scrolls
continuously in the title bar and in the status bar. How annoying!
The scrollTo() Method. This JavaScript method scrolls the content of a window to a
specified x/y coordinate pixel position. This method is only useful where there are areas of
the document not viewable within the current viewable area of the window. If you open
up another window, you might want to scroll to a particular place in the window based on
the user's selection from a menu in the main window, or you might want to use scrolling
Search WWH ::




Custom Search