?? 3.25 文字逐個閃亮-霓虹燈效果.htm
字號:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>標題頁</title>
<script language="JavaScript">
text = "歡迎光臨我們的俱樂部"; //顯示的文字
color1 = "gray"; //文字的顏色
color2 = "blue"; //轉換的顏色
fontsize = "6"; //字體大小
speed = 300; //轉換速度 (毫秒)
i = 0;
if (navigator.appName == "Netscape") {//瀏覽器不同,輸出的標簽不同
document.write("<layer id=myDiv visibility=show></layer><br><br><br>");
}
else {
document.write("<div id=myDiv></div>");
}
function changeCharColor()
{
if (navigator.appName == "Netscape") { //Netscape瀏覽器的情況下
document.myDiv.document.write("<center><font face=arial size =" + fontsize + "><font color=" + color1 + ">");
for (var j = 0; j < text.length; j++) {
if(j == i) {
document.myDiv.document.write("<font face=arial color=" + color2 + ">" + Text.charAt(i) + "</font>");
}
else {
document.myDiv.document.write(text.charAt(j));
}
}
document.myDiv.document.write('</font></font></center>');
document.myDiv.document.close();
}
if (navigator.appName == "Microsoft Internet Explorer") //IE瀏覽器的情況下
{
str = "<center><font face=arial size=" + fontsize + "><font color=" + color1 + ">";
for (var j = 0; j < text.length; j++) { //循環輸出指定字體大小和顏色的文本
if( j == i) {
str += "<font face=arial color=" + color2 + ">" + text.charAt(i) + "</font>";
}
else {
str += text.charAt(j);
}
}
str += "</font></font></center>";
myDiv.innerHTML = str; //在div中顯示文本
}
(i == text.length) ? i=0 : i++; //如果i的值不大于文本的長度,則自增
}
setInterval("changeCharColor()", speed); //通過定時器,實現不斷的循環
</script>
</head>
<body>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -