Moving Ahead
Now, lets see how scrolling occurs: We repeatedly show strings in the status bar and keep moving right one character at a time. To achieve this we can use the substring() method of the string object. In our last example, message was a string. We can display a part of this string in the status bar by using the following construct: window.status = message.substring (2, 5). Doing this will display 5 characters of the message string starting from 2nd character (which becomes " am a"). In this way, we can repeatedly display the substring starting from one character ahead.
Now the problem is how to call a function repeatedly. One thing that comes to our mind is the for loop; but that won't work here. The reason is that a for loop can execute a set of statements multiple times when called, but not forever. On the other hand, we need a scrolling function, that scrolls forever. To tell you the proper way: there is built-in function just for repeatedly calling a function of yours. We can use setTimeout() to make the browser call our function at fixed time intervals. For example, if we want that our scrolling function should be called every time after 5 milliseconds, we can say: setTimeout ("scrol()", 5). I hope things are clear now. Following code will explain everything.