Rotating Text Banner


把以下代码放在<head></head>之间: <script language="JavaScript"> function update(msg) { var pad_str=""; n = msg.length; if(n<81) { pad = (81-n)/2; for(var i=0; i&lt;pad; i++) { pad_str+=" "; } } CurrentMsg = pad_str + msg; document.messages.field.value = CurrentMsg; clearTimeout(timer); timer = setTimeout("idleMsg()",5000); } function MakeArray(n) { this.length=n; for(var i = 1; i&lt;= n; i++) { this[i] = ""; } return(this); } var index = 1; var notice_num = 4; var notices = new MakeArray(notice_num); notices[1] = "MESSAGE #1"; notices[2] = "MESSAGE #2"; notices[3] = "MESSAGE #3"; notices[4] = "MESSAGE #4"; function idleMsg() { update(notices[index++]); if(index>notice_num) { index=1; } } </script> 把以下代码放在HTML文件任意地方: <form name="messages" onSubmit="return false"> <input type="text" name="field" size=60 height=5 value=""> </form>