逐个变色走动的文字效果

下面是效果

COPY下面代码到你网页中<body></body>标签中即可......

<script language="JavaScript">
text = "新的一年里,电脑学习网将带给你全方位的服务!!!"; color1 = "FF0000"; color2 = "0000FF"; fontsize = "4"; speed = 360
i = 0;
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") {
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") {
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;
}
(i == text.length) ? i=0 : i++;
}
setInterval("changeCharColor()", speed);
</script>


在这个效果中,你只需将蓝色部分的文字改成你自己要显示的文字,然后将代码加入到你网页<body></body>标签中即可实现..在此希望你可以给本站做链接,谢谢!!!

关闭这个窗口