请教高手!!!

rickhunterchen 2006-04-29 01:08:33
我有这样一段js:
var j=1;
function addRow(the_table){
//追加行
var newRow = the_table.insertRow();

newRow.style.display = "";
var cellNum = the_table.rows[4].cells.length;

//追加列
for (colIndex = 0; colIndex < cellNum; colIndex++) {
var newCell = newRow.insertCell();
initTblCell(newCell,j,the_table);
}
j++;
}

function initTblCell(cell,j,the_table){

var lastCell = the_table.rows[4].cells[cell.cellIndex];
cell.innerHTML = lastCell.innerHTML;


if (cell.children != null && cell.children.length > 0) {
for(childIndex = 0; childIndex < cell.children.length; childIndex++) {
var child = cell.children[childIndex];

switch(child.type) {
case "text":

//if(child.onkeyup!=null){
//child.onkeyup="function anonymous()"+
// "{"+
// "check_zz("+j+")"+
// "}";
//child.onkeyup="check_zz("+j+")";
//child.onkeyup="function anonymous(){check_zz(1)}";
//alert(child.onkeyup);
//alert(cell.innerHTML);
//}

if(child.onclick!=null){
alert(child.onclick);
child.onClick="alert('单击....')";

// alert(cell.innerHTML);
}
child.value = "";
break;
case "":
child.href="javascript:openNewWindow("+"'common/rkd_select.jsp?rkdField=m_ccpfhtzdcb_rkbh("+j+")&&wzidField=m_ccpfhtzdcb_wzid("+j+")&&jldwField=m_ccpfhtzdcb_jldw("+j+")&&scdhField=m_ccpfhtzdcb_scdh("+j+")&&cpmcField=m_ccpfhtzdcb_cpmc("+j+")&&htbhField=m_ccpfhtzdcb_htbh("+j+")&&formName=ccpfhtzdForm','入库单号选择','height=400,width=650,toolbar=no,scrollbars=1')"
break;

}
}

}
cell.className = lastCell.className;
cell.align = lastCell.align;
cell.height = lastCell.height;
}

function dellRow(the_table){
var objRow=the_table.rows.length-1;
if(objRow != 4){
the_table.deleteRow(objRow);
j--;
}
}

其中有这样一句话:
alert(child.onclick);
打印出来的是:
function anonymous(){ alert('单击');
};
为什么不是直接打印出:
alert('单击');

求解
...全文
98 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
rickhunterchen 2006-04-29
  • 打赏
  • 举报
回复
万分感激!
clare2003 2006-04-29
  • 打赏
  • 举报
回复
改称这样

if(child.onclick!=null){
alert(child.onclick);
child.onClick=function(){"alert('单击....')";}

// alert(cell.innerHTML);
}

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧