在網頁中經常有人使用Swish來做文本輸出的打字效果其實JavaScript也能做出那樣的效果按如下方法在HTML文件中加入JavaScript代碼便可
第一步把如下代碼加入<head>區域中
<SCRIPT LANGUAGE=JavaScript>
<! Original: Tarjei Davidsen () >
<! This script and many more are available free online at >
<! The JavaScript Source!! >
<! Begin
var max=;
function textlist() {
max=textlistargumentslength;
for (i=; i<max; i++)
this[i]=textlistarguments[i];}
tl = new textlist( 在此輸入要輸出的文字);
var x = ; pos = ;
var l = tl[]length;
function textticker() {
documenttickformtickfieldvalue = tl[x]substring( pos) + _;
if(pos++ == l) {
pos = ;
setTimeout(textticker() );
if(++x == max) x = ;
l = tl[x]length;
} else
setTimeout(textticker() );}
// End ></script>
第二步把如下代碼加入<body>區域中
<form name=tickform>
<textarea name=tickfield rows= cols= wrap=virtual>The news will appear here when the page has finished loading</textarea></form>
第三步把<body>改為<body bgcolor=#fefd OnLoad=textticker()>
OK大功告成!
From:http://tw.wingwit.com/Article/program/Java/Javascript/201311/25314.html