Text Scrolling in JavaScript


Note how the ScrollMessage function calls itself again after each execution. This looks like recursion but actually is not. It is just simple repetition.


var msg = "This is an example of a scrolling message. Cooorrrr !!!  Very tacky these days";
var spacer = "...          ...";
var pos = 0;
function ScrollMessage ()
{
	window.status = msg.substring (pos, msg.length) + spacer + msg.substring (0, pos);
	pos++;
	if (pos > msg.length) pos = 0;
	window.setTimeout ("ScrollMessage()", 200);
}
ScrollMessage();