Function is a keyword and is used to begin the function. ScrollingMessage() is the name of the function. A brace ( { ) is needed to begin the function. Be sure there is a space before the brace.
function ScrollingMessage() {
The window.status indicates there is going to be a display on the status bar. The display includes the message (MyMessage) which you want to begin at the very beginning (position 0), the spaces, and the message again.
window.status = MyMessage.substring(position, MyMessage.length) + spaces + MyMessage.substring(0, position);
The position is incremented by one. This can be written "position = position + 1". This gives the message the appearance of scrolling.
position++;
This checks to see if the position is larger than the length of the message. If it is, the position is reset to 0 and the message begins again.
if (position > MyMessage.length) position = 0;
The window.setTimeout method is used to run the function after a delay. This delay is set to .2 seconds. Increase this value to make the scrolling appear to be slower.
window.setTimeout("ScrollingMessage()",200);
The right brace ends the function.
}
This statement is used to call the function you just wrote.
ScrollingMessage();