在一个javascript文件中如何根据一个整型变量的值来改变另一个Jsp页面中的一个链接的背景颜色???? <a href="xxxx"><font id="FontColor" color="blue">链接</font></a>if(i==1) FontColor.color="red";else FontColor.color="yellow"; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 先把颜色放到数组里面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]; 我的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也不行 } } 可以了,是getElementById("historyRec")写错了 table的框线边距在css中怎么设置啊?? 使用iframe页面布局问题 关于innerHTML 写出file的问题 js错误 js关于createelement 的问题(急) JS一个框架内的页面能不能调用其他框架内的页面的变量? 请教一段简单的javascript代码如何编写? setRequestHeader设置头信息 如何实现双击左边的下拉框内容后,其内容被添加到右边的下拉框中? vue 实现页面多个时间选择器 请教三级菜单问题 , 谢谢 如何用javascript程序控制ie选择“工具-〉Internet选项-〉高级中的“打印背景图片””。
n为你输入的参数
for(var i=0;i<arrname.length;i++){
if(i==n) document.all.body.backgroundColor=arrname[i];
}
直接就可以了document.all.body.backgroundColor=arrname[n];
<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也不行
}
}