js控制文字闪烁的代码

时间:2022-08-25 12:23:26

<body bgcolor="#fef4d9" onload="TimerID2=setTimeout('fLi2()',500)" onunload="clearTimeout(TimerID2)">
<script language="JAVASCRIPT">
     colors2 = new Array(2); 
     colors2[0]="#F00";
     colors2[1]="#00F";

     var i=0;
     function fLi2() {
             line2.style.visibility = "visible";
             if (i<2) {
                     line2.style.color = colors2[i];
                     i++;
                     timerID2 = setTimeout( "fLi2()", 800);
             }
             else {
             i=0;
             line2.style.visibility="hidden";
             TimerID2=setTimeout("fLi2()",10);
             }
       }
     </script>

     <a id=line2 href="#">
     JavaScript Planet
     </a>
</body>


    颜色还可以添加多个,增加的时候数组的数量别忘了也跟着变