近日一朋友问我怎么做到Mouse放到控件上时让控件的文字闪烁,就写了以下的代码,
拿出来共享一下,希望大家批评指教
代码如下:
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<SCRIPT LANGUAGE="JavaScript">
var tid = null;
function blink(objId){
var obj = eval("document.all." + objId );
var colors=new Array();
colors[0]="#FF0000";
colors[1]="#00FF00";
colors[2]="#0000FF";
colors[3]="#FF6600";
colors[4]="#9933CC";
colors[5]="#996600";
colors[6]="#330066";
colors[7]="#669933";
var i = parseInt((colors.length-0+1) * Math.random() + 1)
obj.style.color = colors[i];
tid = setTimeout("blink('"+ objId +"')",50);
}
function reset(objId){
clearTimeout(tid);
var obj = eval("document.all." + objId );
obj.style.color = '#000000';
}
</SCRIPT>
<a href='#' id='dd' onmouseOver="blink(this.id)" onmouseOut="reset(this.id)">ffffffffffffffffffff</a>