<a href="xxxx"><font id="FontColor" color="blue">链接</font></a>if(i==1) FontColor.color="red";
else FontColor.color="yellow";

解决方案 »

  1.   

    先把颜色放到数组里面arrname=new Array('','','',.....,'');
    n为你输入的参数
    for(var i=0;i<arrname.length;i++){
      if(i==n) document.all.body.backgroundColor=arrname[i];
    }
    直接就可以了document.all.body.backgroundColor=arrname[n];
      

  2.   

    我的jsp代码放在a.jsp中,javascript代码放在b.js中a.jsp中的代码如下:
    <table width=623 class="tableBorderStyle" cellspacing=0 cellpadding=1 >
      .....
      <tr  class="tdBottomBorder2" valign="top">
         <a nohref style="cursor:hand" onClick="return getHistory()" id="historyRec" title="历史记录"><u>受理历史记录</u></a>
      </tr>
      ....
    /table> b.js中的代码如下:
      var form;
      function getDetailInfo()
      {
        int nColorFlag; 
        if(nColorFlag=0){
           //把jsp页面中的"受理历史记录"背景颜色改成红色
           form.getElementById(historyRec).style.background-color="red";
           //document.getElementById(historyRec).style.background-color="red";//用document也不行
         }
      }
      

  3.   

    可以了,是getElementById("historyRec")写错了