Js实现滚动变色的文字效果
以下是源代码:
<html> <head> <metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/> <title>滚动变色的文字js特效</title> </head> <body> <divstyle="width:736px;"> 请注意下方的文字,部分文字染成红色,且红色循环移动。<ahref="http://keleyi.com/a/bjad/bd55blos.htm"target="_blank">原文</a> </div> <scripttype="text/javascript"> varmessage="欢迎访问柯乐义网,这里有web前端等学习资料。" varneonbasecolor="#333333" varneontextcolor="#ff0000" varneontextcolor2="#ff3333" varflashspeed=100 varflashingletters=8 varflashingletters2=2 varflashpause=0 varn=0 if(document.all||document.getElementById){ document.write('<fontcolor="'+neonbasecolor+'">') for(m=0;m<message.length;m++) document.write('<spanid="neonlight'+m+'">'+message.charAt(m)+'</span>') document.write('</font>') } else document.write(message) functioncrossref(number){ varcrossobj=document.all?eval("document.all.neonlight"+number):document.getElementById("neonlight"+number) returncrossobj } functionneon(){ if(n==0){ for(m=0;m<message.length;m++) crossref(m).style.color=neonbasecolor } crossref(n).style.color=neontextcolor if(n>flashingletters-1)crossref(n-flashingletters).style.color=neontextcolor2 if(n>(flashingletters+flashingletters2)-1)crossref(n-flashingletters-flashingletters2).style.color=neonbasecolor if(n<message.length-1) n++ else{ n=0 clearInterval(flashing) setTimeout("beginneon()",flashpause) return } } functionbeginneon(){ if(document.all||document.getElementById) flashing=setInterval("neon()",flashspeed) } beginneon() </script> <div><br/><ahref="http://keleyi.com"target="_blank">keleyi.com</a></div> </body> </html>