?? 7-2.htm
字號:
<script language=javascript>
var style = document.all, both = style, idme=908601;<!--定義變量-->
if (style) { layerRef = 'document.all'; styleRef = '.style'; }<!--對變量進行賦值-->
function writeOnText(obj, str) {
eval(obj+'.innerHTML= str'); <!--向窗口中寫入字符串-->
}
var dispStr = new Array("歡迎來到javascript世界!");
var overMe=0;
function txtTyper(str, idx, idObj, spObj, clr1, clr2, delay, plysnd) {
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)
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', 300, 0);<!--設置參數,調用函數txtTyper-->
}
</script>
<body onload=init() >
<DIV class=ttl1 id=ttl0></DIV>
</body>
</html>
<!--本例程實現了呈變色并逐個顯示的文字-->
<!--同時本例程還支持對喇叭的調用-->
<!--定時器的使用-->
<!--逐個顯示效果的實現過程-->
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -