这是个简单的在状态栏显示字的代码,不过有些地方不太懂,比如makeArray有什么用呢,stopBanner()这个有什么用,timerID的作用是什么呢~请大家给解释一个,谢谢~
<SCRIPT LANGUAGE=javascript>
function makeArray(n) {
this.length = n;
}
function stopBanner() {
if (bannerRunning)
clearTimeout(timerID);
bannerRunning = false;
}
function startBanner() {
stopBanner();
showBanner();
}
function showBanner() {
var text = ar[currentMessage];
if (offset < text.length) {
if (text.charAt(offset) == " ")
offset++;
var partialMessage = text.substring(0, offset + 1);
window.status = partialMessage;
offset++;
timerID = setTimeout("showBanner()", speed);
bannerRunning = true;
} else {
offset = 0;
currentMessage++;
if (currentMessage == arlength)
currentMessage = 0;
timerID = setTimeout("showBanner()", pause);
bannerRunning = true;
}
}
var speed = 100 /* 数越小速度越快 */
var pause = 1000 /* 数越大停顿越长 */
var timerID = null;
var bannerRunning = false;
var currentMessage = 0;
var offset = 0;
var arlength = 3; /* 字幕的条数 */
var ar = new makeArray(arlength);
ar[0] = "欢迎光临";
ar[1] = "祝您愉快!";
ar[2] = "谢谢!";
</SCRIPT>