?? 7-19.htm
字號:
<script language="JavaScript">
function assignArray(text,delay) {
this.text=text<!--返回text-->
this.delay=delay<!--返回delay-->
}
function createArray() {
fadecolor=new Array("green","yellow","#666666","blue","#CCCCCC","red")<!--新建數組,用來存儲顏色-->
msg=new Array()
msg[0]=new assignArray("WelcomeTo",1000)<!--第三條信息-->
msg[1]=new assignArray("JavaScriptWorld!",1000)<!--第三條信息-->
setTimeout("typeIt()", 1000)<!--延時1秒調用typeit函數-->
}
var msgNo=0;var character=1;var colorNo=0;var fixColor=1 ;var colorCheck=0<!--定義變量,并且初始化-->
function typeIt() {
var insertHTML=""
if(msgNo <= msg.length-1) {
if(character <= msg[msgNo].text.length || colorCheck < msg[msgNo].text.length) {<!--如果正在顯示某一條信息-->
colorCheck=0
for(var charCheck=0; charCheck<character; charCheck++,colorNo--,fixColor--){
if(fixColor>5)colorNo=5<!--設置顏色-->
if(colorNo==5)colorCheck+=1<!--設置顏色-->
<!--設置insertHTML的-->
insertHTML += '<SPAN style="font-family:Arial Black; font-size:15pt; color:'+fadecolor[colorNo]+'">' + msg[msgNo].text.substring(charCheck, charCheck+1) + '</SPAN>'
}
if (document.all) {<!--對于ie瀏覽器-->
document.all.typeWriter.innerHTML = insertHTML<!--輸出insertHTML中的內容-->
}
setTimeout("typeIt()", 50)<!--每隔50毫秒,顯示一個字-->
character++<!--顯示下一個字-->
colorNo=character-1<!--變化顏色-->
fixColor=character<!--變化顏色-->
}
else {<!--一條信息剛顯示完-->
character=1<!--下一條信息的第一個字符-->
colorNo=character-1<!--設置顏色-->
fixColor=character<!--設置顏色-->
setTimeout("typeIt()", msg[msgNo].delay)<!--設置周期時間-->
msgNo++<!--轉到下一條信息-->
}
}
}
</script>
<body bgcolor="#ffffff" onLoad="createArray()" text="#ffffff">
<div ID="typeWriter" style="position:absolute; left:20; top:10; height:200; width:70">
<!--本例程實現了超級文字顯示-->
<!--垂直顯示文字的技巧-->
<!--絢麗顏色的變化效果的實現過程-->
<!--定時器的使用-->
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -