<div class="htmlarea"> <textarea id="runcode93845"> <title>JavaScript数组文字</title> <script language="JavaScript"> var i = 0; var TextNumber = -1; var TextInput = new Object(); var HelpText=""; var Text = ""; var Speed=50; var message=0; var addPadding="\r\n"; TextInput[0] = "脚本之家庆祝日!"; TextInput[1] = "脚本之家感谢广大朋友多年来的支持……"; TextInput[2] = "我们将一如继往继续为大家奉献更好的源码资源!"; TotalTextInput = 2; // (0, 1, 2) var Version = navigator.appVersion; if (Version.substring(0, 1)==3) { Speed=200; addPadding=""; } for (var addPause = 0; addPause <= TotalTextInput; addPause++) {TextInput[addPause]=addPadding+TextInput[addPause];} var TimerId var TimerSet=false; function nextMessage() { if (!TimerSet) { TimerSet=true; clearTimeout (TimerId); if (TextNumber>=TotalTextInput) { alert("This is the end of the list!"); TimerSet=false; } else { TextNumber+=1; message=TextNumber+1; document.forms[0].elements[2].value= message; Text = TextInput[TextNumber]; HelpText = Text; } teletype(); } } function teletype() { if (TimerSet) { Text=rollMessage(); TimerId = setTimeout("teletype()", Speed); document.forms[0].elements[0].value=Text; } } function rollMessage () { i++; var CheckSpace = HelpText.substring(i-1, i); CheckSpace = "" + CheckSpace; if (CheckSpace == " ") {i++;} if (i >= HelpText.length+1) { TimerSet=false; Text = HelpText.substring(0, i); i=0; return (Text); } Text = HelpText.substring(0, i); return (Text); } function initTeleType() { Text="\r\n Manual Tele-Type Display"; document.forms[0].elements[0].value=Text; } function lastMessage() { if (!TimerSet && TextNumber!=-1) { TimerSet=true; clearTimeout (TimerId); if (TextNumber<=0) { alert("This is the beginning of the list!"); TimerSet=false; } else { TextNumber-=1; message=TextNumber+1; document.forms[0].elements[2].value= message; Text = TextInput[TextNumber]; HelpText = Text; } teletype(); } } </script> <form> <table cellspacing="0" cellpadding="0" width="420"> <tr> <td width="100%" colspan="3" valign="top"><div align="center"><textarea name="teletype" rows="3" cols="49" wrap="yes"> </textarea></div></td> </tr> <tr align="center"> <td width="30%" bgcolor="#0000A0" valign="top"><input type="text" value="共3条" size="5" name="1"></td> <td width="30%" bgcolor="#0000A0" valign="top"><input type="button" value="阅 读" onclick="nextMessage()"></td> </tr> </table> </form> </textarea><br><input onclick="runEx('runcode93845')" type="button" value="运行代码"> <input onclick="doCopy('runcode93845')" type="button" value="复制代码"> <input onclick="doSave(runcode93845)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div>