<div class="htmlarea"> <textarea id="runcode44846"> <title>颜色变幻像字符输入一样的欢迎词</title> <div id="textDiv"> </div> </textarea> <br><input onclick="runEx('runcode44846')" type="button" value="运行代码"><input onclick="doCopy('runcode44846')" type="button" value="复制代码"> <input onclick="doSave(runcode44846)" type="button" value="保存代码"> <a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">[Ctrl A 全选 注:</a>如需引入外部Js需刷新才能执行</div>]<script language="JavaScript"> var someText = "Welcome to Jb51.net"; var aChar; var aSentence; var i=0; var colors = new Array("FF0000","FFFF66","FF3399","00FFFF","FF9900","00FF00"); var aColor; function loadText() { aColor = colors[Math.floor(Math.random()*colors.length)]; aChar = someText.charAt(i); if (i == 0) aSentence = aChar; else aSentence += aChar; if (i < 50) i++; if (document.all) { textDiv.innerHTML= "<font color='#"+aColor+"' face='Tahoma' size='5'><i>"+aSentence+""; setTimeout("loadText()",100); } else if (document.layers) { document.textDiv.document.write("<font color='#"+aColor+"' face='Tahoma' size='5'><i>"+aSentence+""); document.textDiv.document.close(); setTimeout("loadText()",100); } else if (document.getElementById) { document.getElementById("textDiv").innerHTML = "<font color='#"+aColor+"' face='Tahoma'size='5'><i>"+aSentence+""; setTimeout("loadText()",100); } } </script>