试试看?<script>
var arrColor=["red","yellow","purple","lime"],count=0,timer;
function document.onmouseover(){
if(event.srcElement.tagName=="A")timer=setInterval("count=++countarrColor.length;status=count;"+event.srcElement.uniqueID+".runtimeStyle.color=arrColor[count];",300)
}
function document.onmouseout(){
if(event.srcElement.tagName=="A"){clearInterval(timer);event.srcElement.runtimeStyle.color=event.srcElement.style.color}0D
}
</script>
<a href=a>aaaaaaa</a>
<a href=b style="color:#8080ff">bbbbbb</a>
0A

解决方案 »

  1.   

    to:jhlcss(阿龙) 说的对,颜色是渐变的。
    to:qiushuiwuhen(秋水无恨)  不止是几种颜色,而是渐变。
      

  2.   

    <HTML>
    <HEAD>
    <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
    <TITLE></TITLE>
    <SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
    <!--
    var iColor=0x0;
    var id;
    function testlink_onmousemove() {

    testlink.style.color=0x0;
    id=setInterval(setColor,1000);

    }function setColor(){
    if(iColor>0xffffff)
    iColor=0x0;
    testlink.style.color=iColor;
    iColor=iColor+0x2;
    }function testlink_onmouseout() {
    testlink.style.color="blue";
    clearInterval(id);
    }//-->
    </SCRIPT>
    </HEAD>
    <BODY><P><a href="" id=testlink LANGUAGE=javascript onmousemove="return testlink_onmousemove()" onmouseout="return testlink_onmouseout()">链接颜色渐变</a></P></BODY>
    </HTML>
      

  3.   

    <script>
    var color=0,count=0,timer,rate=24,time=36;//rate设置速度;time,时间间隔
    function document.onmouseover(){
    if(event.srcElement.tagName=="A")timer=setInterval("color=(count++)*rate;if(color>0xffffff){count=0;color=0;};"+event.srcElement.uniqueID+".runtimeStyle.color=color;",time)
    }
    function document.onmouseout(){
    if(event.srcElement.tagName=="A"){clearInterval(timer);event.srcElement.runtimeStyle.color=event.srcElement.style.color}
    }
    </script>
    <a href=a>aaaaaaa</a>
    <a href=b style="color:#8080ff">bbbbbb</a>
    感觉:极度不爽
      

  4.   

    to: fokker(独孤龙)  your sulotion is good ,but it still has a bug ,that is when onmouseout ,it can stop change color and to restore the color.
      

  5.   

    sorry ,forget the last message,and this one is correct oneto: fokker(独孤龙)  your sulotion is good ,but it still has a bug ,that is when onmouseout ,it can not stop change color and to restore the color.
      

  6.   

    to:  weidegong(weidegong)  good idea ,you can try that?
      

  7.   

    to:  weidegong(weidegong)  "感觉:极度不爽" what is your mean?
      

  8.   

    个人意见当color在#339900-#ffffff变化时较好看,(我比较喜欢绿,黄,红)to: Lostinet(lostinet.d2g.com)  不错,挺cool。
      

  9.   

    所谓感觉极度不爽,就是说从0到0xffffff变化效果极为难看。远不如淡入淡出效果来得好
      

  10.   

    我发现当初始定义为16进制数的i自加时,仍然是被作为10进制来处理的,因此需要将i转换成16进制的color,我想了很久,ToHex函数实在写得太笨了,让大家见笑了,应该有很简单的代码,希望大家不吝赐教。试了i每次加1或加10,效果都不太好,可能是步长太短,会在相近的颜色间打转很久的缘故吧。i自加在100以上,效果还可以,不过还是有很多颜色没有出来,我觉得再配合调一调i的自加值和setTimeout中的时间间隔,应该能有好一点的效果吧<script>
    i=0X0;
    var hexch = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');function ToHex(n)
    {
    k1=n%16;if((n-k1)/16>=16)
    {k2=Math.floor(((n-k1)/16)%16);if((n-k1)/16/16>=16)
    {k3=Math.floor(((n-k1)/16/16)%16);if((n-k1)/16/16/16>=16)
    {k4=Math.floor(((n-k1)/16/16/16)%16);if((n-k1)/16/16/16/16>=16)
    {k5=Math.floor(((n-k1)/16/16/16/16)%16);if((n-k1)/16/16/16/16/16>=16)
    k6=Math.floor(((n-k1)/16/16/16/16/16)%16);else
    k6=Math.floor((n-k1)/16/16/16/16/16);
    }
    else
    {k5=Math.floor((n-k1)/16/16/16/16);k6=0;}
    }
    else
    {k4=Math.floor((n-k1)/16/16/16);k5=0;k6=0;}
    }
    else
    {k3=Math.floor((n-k1)/16/16);k4=0;k5=0;k6=0;}
    }
    else
    {k2=Math.floor((n-k1)/16);k3=0;k4=0;k5=0;k6=0;}return (hexch[k6]+hexch[k5]+hexch[k4]+hexch[k3]+hexch[k2]+hexch[k1]);
    }function changecolor()
    {
    color=ToHex(i);
    color="#"+color;
    mya.style.color=color;
    if(i<0XFFFFFF)
    i+=100;
    else
    i=0;
    round=setTimeout("changecolor()",10)
    }
    </script>
    <a id=mya style="color='red'" href="javascript:void(0)" onmouseover="changecolor()" onmouseout="clearTimeout(round);this.style.color='red'">color</a>
      

  11.   

    function d2h(d)
    {
    return d.toString(16);
    }
    function h2d(h)
    {
    return parseInt(h,16);
    }
    alert(h2d(d2h(123)));
    alert(d2h(h2d("7b")));
      

  12.   

    我现在能实现的功能是:在我点一个菜单的时候。当前菜单的颜色要改变,其他的菜单的颜色恢复默认值,我现在遇到的问题是:当我点主菜单的时候。其他的主菜单可以恢复默认颜色,但。子菜单不恢复恢复默认颜色。当我点子菜单的时候。其他的子菜单可以恢复默认颜色,但。刚刚点过的主菜单不恢复恢复默认颜色。不知道什么原因,帮我看看,很急。 
    <html> 
    <head> 
    <meta http-equiv="Content-Language" content="zh-cn"> 
    <title>菜单</title> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
    <link rel="stylesheet" href="include/Font.css"> 
    </head> 
    <script language="JavaScript"> 
    <!-- 
    function setColor() 

    window.event.cancelBubble=true; 
    objSRC=window.event.srcElement; 
    while(objSRC.tagName!="TR") 

    objSRC=objSRC.parentNode; 

    for(i=0;i<objSRC.parentNode.children.length;i++) 

    objSRC.parentNode.children(i).bgColor="#637fb9"; 
    objFont=objSRC.parentNode.children(i).children(1); 
    while(objFont.tagName!="FONT") 

    objFont=objFont.children(0); } 
    objFont.color=""; 
    } objSRC.bgColor="#637fb9"; 
    window.event.srcElement.color="#FFFF66"; 

    --> 
    </script> 
    <SCRIPT LANGUAGE="JavaScript"> 
    <!-- 
    var bV=parseInt(navigator.appVersion); 
    var NS4=(document.layers) ? true : false; 
    var IE4=((document.all)&&(bV>=4))?true:false; 
    var ver4 = (NS4 || IE4) ? true : false; function expandIt(){return} 
    function expandAll(){return} 
    function nomsg(){self.status="";} if(ver4){ 
    isExpanded = false; function getIndex(el) { 
    ind = null; 
    for (i=0; i<document.layers.length; i++) { 
    whichEl = document.layers[i]; 
    if (whichEl.id == el) { 
    ind = i; 
    break; 


    return ind; 

    function arrange() { 
    nextY = document.layers[firstInd].pageY + document.layers[firstInd].document.height; 
    for (i=firstInd+1; i<document.layers.length; i++) { 
    whichEl = document.layers[i]; 
    if (whichEl.visibility != "hide") { 
    whichEl.pageY = nextY; 
    nextY += whichEl.document.height; 



    function initIt(){ 
    if (NS4) { 
    for (i=0; i<document.layers.length; i++) { 
    whichEl = document.layers[i]; 
    if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide"; 

    arrange(); 

    else { 
    tempColl = document.all.tags("DIV"); 
    for (i=0; i<tempColl.length; i++) { 
    if (tempColl(i).className == "child") tempColl(i).style.display = "none"; 



    function expandIt(el) { 
    if (!ver4) return; 
    if (IE4) {expandIE(el)} else {expandNS(el)} 
    } function expandIE(el) { 
    whichEl = eval(el + "Child"); 
    whichIm = event.srcElement; if (whichEl.style.display == "none") { 
    whichEl.style.display = "block"; 
    whichIm.src = "images/midminus.gif"; 

    else { 
    whichEl.style.display = "none"; 
    whichIm.src = "images/midplus.gif"; 


    function expandNS(el) { 
    whichEl = eval("document." + el + "Child"); 
    whichIm = eval("document." + el + "Parent.document.images['imEx']"); 
    if (whichEl.visibility == "hide") { 
    whichEl.visibility = "show"; 
    whichIm.src = "images/midminus.gif"; 

    else { 
    whichEl.visibility = "hide"; 
    whichIm.src = "images/midplus.gif"; 

    arrange(); 
    } function showAll() { 
    for (i=firstInd; i<document.layers.length; i++) { 
    whichEl = document.layers[i]; 
    whichEl.visibility = "show"; 

    } } 
    //--> 
    </SCRIPT> 
    <body leftmargin="0" topmargin="0" bgcolor="#FFFFFF"> 
    <table border="0" cellspacing="0" cellpadding="0" width="155" height="600"> 
    <tr> 
    <td height="655" width="154" valign="top" bgcolor="#637fb9"> 
    <div align="center"> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
    <tr valign="top"> 
    <td height="46"> 
    <div align="center"><img src="images/sys01.gif" width="154" height="83"></div> 
    </td> 
    </tr> 
    </table> 
    <br> 
    <br> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
    <tr> 
    <td width="13%"> 
    </td> 
    <td width="87%" valign="top"><img src="images/line.gif" width="16" height="16"></td> 
    </tr> 
    </table> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
    <tr bgcolor="#637fb9"> 
    <td height="30" width="36" bgcolor="#637fb9"> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0" height="30"> 
    <tr> 
    <td width="37"> 
    </td> 
    <td width="10" background="images/line.gif" valign="top"><img src="images/lastblk.gif" width="16" height="16"></td> 
    </tr> 
    </table> 
    </td> 
    <td height="30" width="118" valign="top"> <a href="syse/syse01.htm" target="mainFrame" onClick="setColor()"><font color="#FFFF66">人事变动</font></a></td> 
    </tr> 
    <tr bgcolor="#637fb9"> 
    <td width="36" bgcolor="#637fb9"> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0" height="30"> 
    <tr> 
    <td width="37"> 
    </td> 
    <td width="10" background="images/line.gif" valign="top"><img src="images/lastblk.gif" width="16" height="16"></td> 
    </tr> 
    </table> 
    </td> 
    <td width="118" height="30" valign="top"> <a href="syse/syse02.htm" target="mainFrame" onClick="setColor()"><font color="">人事档案</font></a></td> 
    </tr> 
    <tr bgcolor="#637fb9"> 
    <td width="36" bgcolor="#637fb9" valign="top"> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0" height="20"> 
    <tr> 
    <td width="37" height="20"> 
    </td> 
    <td width="10" background="images/line.gif" valign="top" height="20"><a href="#" onClick="expandIt('elOne'); return false"><img src="images/midminus.gif" width="16" height="16" border="0"></a></td> 
    </tr> 
    </table> 
    </td> 
    <td width="118" valign="top"> <a href="#" onClick="setColor()"><font color="">组织管理</font></a> 
    </td> 
    </tr> 
    </table> 
    <div ID="elOneChild" CLASS="child" style="margin-left: 0.5px"> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
    <tr> 
    <td width="24%"> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0" height="50"> 
    <tr> 
    <td width="20" height="30"> 
    </td> 
    <td width="17" background="images/line.gif" valign="top" height="30"></td> 
    </tr> 
    </table> 
    </td> 
    <td width="76%"> 
    <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center"> 
    <tr bgcolor="#637fb9"> 
    <td width="18%" background="images/line.gif"><img src="images/lastblk.gif" width="16" height="16"></td> 
    <td width="82%" height="25"><a href="syse/syse03-1.htm" target="mainFrame" onClick="setColor()"><font color="">组织框架</font><a></a></a></td> 
    </tr> 
    <tr bgcolor="#637fb9"> 
    <td width="18%" valign="top"><img src="images/lastblk.gif" width="16" height="16"></td> 
    <td width="82%" height="25"><a href="syse/syse03-2.htm" target="mainFrame" onClick="setColor()"><font color="">公司信息</font><a></a></a></td> 
    </tr> 
    </table> 
    </td> 
    </tr> 
    </table> 
    </div> 
    <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
    <tr> 
    <td width="14%"> 
    </td> 
    <td width="86%" valign="top"><img src="images/bj.gif" width="97" height="8"></td> 
    </tr> 
    </table> 
    </div> 
    </td> 
    <td width="1" valign="top" background="images/bj04.gif" height="655"> 
    </td> 
    </tr> 
    </table> 
    </body> 
    <SCRIPT LANGUAGE="JavaScript1.2"> 
    <!-- 
    if(NS4){ 
    firstEl = "elOneParent"; 
    firstInd = getIndex(firstEl); 
    showAll(); 
    arrange(); 

    //--> 
    </SCRIPT> 
    <SCRIPT LANGUAGE="JavaScript"> <!-- hide function goHist(a) { history.go(a); } //--> </SCRIPT> 
    </html>
      

  13.   

    谢谢Lostinet的提示,这下简单多了 
    <script>
    i=0X0;
    function d2h(d)
    {
    return d.toString(16);
    }function changecolor()
    {
    color=d2h(i);
    str="";
    for(j=0;j<6-color.length;j++)
    str+="0";
    color="#"+str+color;
    mya.style.color=color;
    if(i<0XFFFFFF)
    i+=100;
    else
    i=0;
    round=setTimeout("changecolor()",10)
    }
    </script>
    <a id=mya style="color='red'" href="javascript:void(0)" onmouseover="changecolor()" onmouseout="clearTimeout(round);this.style.color='red'">color</a>
      

  14.   

    <BODY BGCOLOR="red">
    <SCRIPT language=JavaScript>             
    <!-- Begin             
    text = "你过得还好吗,朋友!^_^你还想我吗";             
    color1 = "white";              
    color2 = "#00FF00";
    fontsize = "1.5";              
    speed = 250;              
                 
    i = 0;             
    if (navigator.appName == "Netscape") {             
    document.write("<layer id=a visibility=show ></layer><br><br><br>");             
    }             
    else {             
    document.write("<div id=a></div>");             
    }             
    function changeCharColor() {             
    if (navigator.appName == "Netscape") {             
    document.a.document.write("<p align=left><font face=arial size =" + fontsize + "><font color=" + color1 + ">");             
    for (var j = 0; j < text.length; j++) {             
    if(j == i) {             
    document.a.document.write("<font face=arial color=" + color2 + ">" + text.charAt(i) + "</font>");             
    }             
    else {             
    document.a.document.write(text.charAt(j));             
    }             
    }             
    document.a.document.write('</font></font></p>');             
    document.a.document.close();             
    }             
    if (navigator.appName == "Microsoft Internet Explorer") {             
    str = "<p align=left><font face=arial size=" + fontsize + "><font color=" + color1 + ">";             
    for (var j = 0; j < text.length; j++) {             
    if( j == i) {             
    str += "<font face=arial color=" + color2 + ">" + text.charAt(i) + "</font>";             
    }             
    else {             
    str += text.charAt(j);             
    }             
    }             
    str += "</font></font></p>";             
    a.innerHTML = str;             
    }             
    (i == text.length) ? i=0 : i++;             
    }             
    setInterval("changeCharColor()", speed);             
    // End -->             
    </SCRIPT>
    </BODY>试试这个,改一下应该就可以了。
      

  15.   

    各位不好意思,上午活多,下午开会,没空看。
    非常感谢各位的支持。对于
    Lostinet(lostinet.d2g.com)  seabell(百合心) 两位的suggestion我觉得修改一下color的值效果就会好点。
    虽然 Andrawu(Andrawu) 的效果与我的设想不一样。但还是感谢他(她)的参与。当然还有: qiushuiwuhen(秋水无恨) : fokker(独孤龙)  weidegong(weidegong) : Lostinet(lostinet.d2g.com) 几位。