不錯(cuò)的文字特效,逐字變色效果
更新時(shí)間:2007年04月16日 00:00:00 作者:
<font color="#669900" style="font-weight:bolder;letter-spacing: 2px;"><script language="JavaScript">
text = "www.dbjr.com.cn";
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>
運(yùn)行效果
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁(yè)面才能執(zhí)行]
text = "www.dbjr.com.cn";
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>
運(yùn)行效果
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁(yè)面才能執(zhí)行]
相關(guān)文章
JavaScript 自動(dòng)在表格前面增加序號(hào)
JavaScript 自動(dòng)為表格增加序號(hào),也就是不手動(dòng)添加序號(hào),讓JS自動(dòng)計(jì)算出行數(shù),然后為表格的每行自動(dòng)加一個(gè)序號(hào),行號(hào)列的數(shù)字隨TR 的增加自動(dòng)增加1,我覺(jué)得還挺實(shí)用吧。2009-09-09document對(duì)象execCommand的command參數(shù)介紹
document對(duì)象execCommand的command參數(shù)介紹...2006-08-08網(wǎng)頁(yè)設(shè)計(jì)常用的一些技巧
網(wǎng)頁(yè)設(shè)計(jì)常用的一些技巧...2006-12-12