Message Rotator using JavaScript


This script displays all messages in priority basis i.e; first message first.

<script language="JavaScript">
<!--

var currentmsg = 0
var MsgTime = 2000
var MsgEndTime = 4000
function initArray(n) {

this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '
}
} msg = new initArray(4)
msg[0]="This is Message 1"
msg[1]="Now it is Message 2"
msg[2]="No, do not say I have to do 3 messages"
msg[3]="Yeah, this message, 4, is the last"
function msgrotator() {

window.status = msg[currentmsg]
if (currentmsg > msg.length - 1) {
currentmsg = 0
setTimeout("msgrotator()", MsgEndTime)
}

else {
currentmsg = currentmsg + 1
setTimeout("msgrotator()", MsgTime)
}
}

msgrotator();
//-->
</script>




Added on June 29, 2007 Comment
}