📄 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 + -