HTML and CSS Reference
An ID selector is defined with a style for the div element on line 13.
The size of the div container is defined.
If the text within the div container will not fit within the dimensions of the box,
the overflow property will adjust it to fit.
The image is fixed at this absolute position on the screen and has a dark green,
The scroller() routine (line 8), modified from the original, was found at the Java
Planet Web site and submitted by Dave Methvin. (Thank you Dave, wherever
The initial values used for the scroller() function are assigned values. One is the
speed for the timer, the other the value of an argument to the substr() method.
This anonymous function is called after the document has been loaded. Its pur-
pose is to get a reference to the div element. The getElementById() method returns
a reference to the div element.
The function called scroller() is defined. Its function is to cause the text found in
the <div> container to scroll continuously from the right side of the container.
The window's setTimeout() method is used to call the scroller() function every
200 milliseconds (.2 seconds). It's the timer that creates the action of actually
The div element is a parent node. It has a child node. The value of its first child,
divElement.firstChild.nodeValue , is the textual content of the message; that is, the
text found between the <div></div> tags. The variable msg gets the value of the
The value returned by msg.substr(1) is “ he latest news from Baghdad is not good to-
night. Sand and rain are hindering our troops. The number of refugees continues to in-
crease in the north...” Notice that the first character in the message has been re-
moved. The next substring method will return the first character—
substring(0,1 )—and append it to the first value resulting in “ he latest news from
Baghdad is not good tonight. Sand and rain are hindering our troops. The number of
refugees continues to increase in the north... T ”. All of this is assigned back to the val-
ue of the child node. In 200 milliseconds, the scroller() function is called again,
and the message becomes “ e latest news from Baghdad is not good tonight. Sand and
rain are hindering our troops. The number of refugees continues to increase in the
north... Th ”, and so on.
The scroller() function is called for the first time here.
The <div> tags contain the text of the message that will be scrolled. Its id, “div1” ,
defines the CSS style that will be used, and is the unique identifier that will be