?? twingle.htm
字號:
<html>
<head>
<title>
彩色文字的順序閃爍效果
</title>
</head>
<body>
<script language="JavaScript">
<!-- Begin
text = "HTTP://www.tsinghua.edu.cn/"; //顯示的文字
color1 = "213074"; //文字的顏色
color2 = "red"; //轉換的顏色
fontsize = "4"; //字體大小
speed = 100; //轉換速度 (1000 = 1 秒)
i = 0;
document.write("<br>");
//判斷瀏覽器類型,寫出適合瀏覽器的代碼
if(navigator.appName == "Netscape")
{
document.write("<layer id=a visibility=show></layer><br><br><br>");
}
else
{
document.write("<div id=a></div>");
}
//閃爍效果的實現函數
function changeCharColor()
{
if(navigator.appName == "Netscape") //NetScape瀏覽器下的實現
{
document.a.document.write("<center><font face=arial size =" + fontsize + "><font color=" + color1 + ">");
for(var j = 0; j < text.length; j++)
{
if(j == i)
{
document.a.document.write("<font face=arial color=" + color2 + ">" + Text.charAt(i) + "</font>");
}
else
{
document.a.document.write(text.charAt(j));
}
}
document.a.document.write('</font></font></center>');
document.a.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>";
a.innerHTML = str;//利用div對象的innerHTML屬性來實現動態HTML的運行
}
i++;
if(i == text.length)
i=0;
}
setInterval("changeCharColor()", speed);//遞歸調用
// End -->
</script>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -