打字機打彩色文字

- 中國WEB開發者網絡 (http://www.webasp.net)
-- 網頁特效 (http://www.webasp.net/javascript/)
--- 打字機打彩色文字 (http://www.webasp.net/javascript/1/123.htm)
-- 發佈日期: 2004-06-04
<!-- 網頁特效代碼由[中國WEB開發者網絡:http://www.ChinaWebDev.com]提供! -->
<!-- 要實現此效果需要 3 個步驟: -->

<!-- 第 1 步: -->
<!-- 把下面的代碼加到<HEAD></HEAD>區域中: -->

<SCRIPT language="JavaScript">
<!--

var layers = document.layers, style = document.all, both = layers || style, idme=908601;
if (layers) { layerRef = 'document.layers'; styleRef = ''; } if (style) { layerRef = 'document.all'; styleRef = '.style'; }

function writeOnText(obj, str) {
if (layers) with (document[obj]) { document.open(); document.write(str); document.close(); }
if (style) eval(obj+'.innerHTML= str');
}
//以下是輸出的內容,自己修改即可。
var dispStr = new Array(
"<font color=red size=3>歡迎光臨「網頁特效集錦」...</font><br><font color=green size=3>你知道怎樣在你的網頁中做一個很酷的網頁菜單嗎?</font><br><font color=red size=3>你知道怎樣讓你的網頁背景向上或向下移動嗎?</font><br><font color=blue size=3>你知道怎樣在你的主頁中任意位置顯示一個時鐘嗎?</font><br><font color=red size=3>你知道怎樣在主頁中做特效文字嗎?</font><br><font color=black size=3>你知道怎樣做一個很cool的日曆嗎?</font>"
);

var overMe=0;

function txtTyper(str, idx, idObj, spObj, clr1, clr2, delay, plysnd) {
var tmp0 = tmp1 = '', skip = 0;
if (both && idx <= str.length) {
if (str.charAt(idx) == '<') { while (str.charAt(idx) != '>') idx++; idx++; }
if (str.charAt(idx) == '&' && str.charAt(idx+1) != ' ') { while (str.charAt(idx) != ';') idx++; idx++; }
tmp0 = str.slice(0,idx);
tmp1 = str.charAt(idx++);

if (overMe==0 && plysnd==1) {
if (navigator.plugins[0]) {
if (navigator.plugins["LiveAudio"][0].type=="audio/basic" && navigator.javaEnabled()) {
document.embeds[0].stop();
setTimeout("document.embeds[0].play(false)",100); }
} else if (document.all) {
ding.Stop();
setTimeout("ding.Run()",100);
}
overMe=1;
} else overMe=0;

writeOnText(idObj, "<span class="+spObj+"><font color='"+clr1+"'>"+tmp0+"</font><font color='"+clr2+"'>"+tmp1+"</font></span>");
setTimeout("txtTyper('"+str+"', "+idx+", '"+idObj+"', '"+spObj+"', '"+clr1+"', '"+clr2+"', "+delay+" ,"+plysnd+")",delay);
}
}

function init() {
txtTyper(dispStr[0], 0, 'ttl0', 'ttl1', '#339933', '#99FF33', 50, 0);
}

// -->
</SCRIPT>




<!-- 第 2 步: -->
<!-- 把<BODY>中的屬性代碼改為: -->

<BODY bgcolor="#fef4d9" onload="init()">



<!-- 第 3 步: -->
<!-- 把下面的代碼加到<BODY></BODY>區域中: -->

<DIV class=ttl1 id=ttl0><SPAN class=ttl1></SPAN></DIV>


webasp.net