天天看点

JS特效之打字机效果

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>??澶╄?板?</title>

<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>绯荤?锛?O(????O......寮?濮???澶?.....(*^__^*)</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>娴?璇??版?ょ????</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>

<mce:style type="text/css"><!--

#center{ width:480px; height:360px; margin:0 auto; background-color:green;}

--></mce:style><style type="text/css" mce_bogus="1">#center{ width:480px; height:360px; margin:0 auto; background-color:green;}</style>

????<HTA:Application ID="HTA"

????Applicationname="myApp"

????

????borderstyle="raised"

????caption="yes"

????icon="filename.ico"

????maximizebutton="yes"

????minimizebutton="yes"

????showintaskbar="no"

????singleinstance="no"

????sysmenu="yes"

????version="1.0"

????windowstate="normal"

????scroll="yes">

</head>

<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" 慰nl慰ad="init()">

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

</body>

</html>

?

澶??朵?瀛?涓?hta?煎??冲????

继续阅读