<script> <BR>text = "www.jb51.net"; <BR>color1 = "green"; <BR>color2 = "red"; <BR>speed = 200; <BR>i = 0; <BR>if (navigator.appName == "Netscape") { <BR>} <BR>else { <BR>document.write("<span id=a>"); <BR>} <BR>function changeCharColor() { <BR>if (navigator.appName == "Netscape") { <BR>document.a.document.write("<font color=" + color1 + ">"); <BR>for (var j = 0; j < text.length; j++) { <BR>if(j == i) { <BR>document.a.document.write("<font color=" + color2 + ">" + Text.charAt(i) + "</script>");
}
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 if( j == i) {
str += "" + text.charAt(i) + "";
}
else {
str += text.charAt(j);
}
}
str += "";
a.innerHTML = str;
}
(i == text.length) ? i=0 : i++;
}
setInterval("changeCharColor()", speed);
// End -->
运行效果