您的位置:首页 > 其它

不错的文字特效,逐字变色效果

2007-04-16 00:00 411 查看
<font color="#669900" style="font-weight:bolder;letter-spacing: 2px;"><script language="JavaScript">
text = "www.jb51.net";
color1 = "green"; 
color2 = "red";
speed = 200; 
i = 0;
if (navigator.appName == "Netscape") {
}
else {
document.write("<span id=a></span>");
}
function changeCharColor() {
if (navigator.appName == "Netscape") {
document.a.document.write("<font color=" + color1 + ">");
for (var j = 0; j < text.length; j++) {
if(j == i) {
document.a.document.write("<font color=" + color2 + ">" + Text.charAt(i) + "</font>");
}
else {
document.a.document.write(text.charAt(j));
}
}
document.a.document.write('</font>');
document.a.document.close();
}
if (navigator.appName == "Microsoft Internet Explorer") {
str = "<font color=" + color1 + ">";
for (var j = 0; j < text.length; j++) {
if( j == i) {
str += "<font   color=" + color2 + ">" + text.charAt(i) + "</font>";
}
else {
str += text.charAt(j);
}
}
str += "</font>";
a.innerHTML = str;
}
(i == text.length) ? i=0 : i++;
}
setInterval("changeCharColor()", speed);
// End -->
</script>
</font>  
运行效果
"); } else { document.a.document.write(text.charAt(j)); } } document.a.document.write(''); document.a.document.close(); } if (navigator.appName == "Microsoft Internet Explorer") { str = ""; for (var j = 0; j " + text.charAt(i) + ""; } else { str += text.charAt(j); } } str += ""; a.innerHTML = str; } (i == text.length) ? i=0 : i++; } setInterval("changeCharColor()", speed); // End -->
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息