(231.htm) will include status bar messages that goes from left to right, and looks like a typewriter is typing the message. The main class example above goes from right to left & scrolls. In this exercise have the status bar display several (3 - 4) different messages with a pause (different than the typing speed) between each message.
NOTE: Don't use a for loop - this can get you into major trouble.
A template for possible use: | Actual Code Used: |
var frontPart, backPart;
var myMsg = "Hey, I know JavaScript - check out my
kewl scroller! ... ";
var i = 0;
function scrollMsg() {
frontPart = myMsg.substring(i, myMsg.length);
backPart = myMsg.substring(0, i);
window.status = frontPart + backPart;
if (i < myMsg.length) i++;
else i = 0;
setTimeout("scrollMsg()", 50) ;
}
<Body onLoad="scrollMsg();">
This is an example of a typewriter scrolling message |
i=0;
Index=0;
var myMsg = new Array();
myMsg[0] = "This is a 'Typewriter' message. ";
myMsg[1] = "Want to know how it's done? ";
myMsg[2] = "Learn J a v a S C R I P T
! ! ! ! ";
function scrollMsg() {
window.status = myMsg[Index].substring(0, i + 1);
if (i < myMsg[Index].length) {
i++;
setTimeout("scrollMsg()", 50) ;
}
else {
i = 0;
if (Index == myMsg.length - 1) Index = 0;
else Index++;
setTimeout("scrollMsg()", 1000);
}
}
|
...and here's a tip from the COIN 70b Yahoo! Group
Below is a possible template for 231 where the dots (...) need to be filled in.
...
var i = 0;
var Index = 0;
function typeMsg() {
status = Msg[Index].substring(0, i + 1);
if (i < Msg[Index].length) {
...
setTimeout("typeMsg()", 100);
}
else {
...
if (Index ...) ...++;
else ... = 0;
setTimeout("typeMsg()", 1000);
}
}
...