通过TABLE的ONCLICK事件调用自定义JAVASCRIPT,有问题!望高手不吝赐教。
cs_HH 2002-03-20 09:36:46
<HTML>
<HEAD>
<META http-equiv="content-type" content="text/html;charset=gb2312">
<TITLE></TITLE>
<BASE target=main>
<STYLE>
<!--
BODY {background-color:white;color:black;}
TD {font:10.5pt 宋体;cursor:hand;}
A {font:9pt 宋体;}
A:link {color:yellow;}
A:visited {color:yellow;}
A:hover {color:yellow;background-color:blue;}
TR.hide {display:none;}
TR.show {display:block;}
-->
</STYLE>
</HEAD>
<TABLE border=0 cellspacing=0 cellpadding=0 width=235 align="center">
<TR>
<TD colspan=2 style="cursor: default" width="312"></TD>
</TR>
<TR>
<TD height=20 width="170"> </TD>
</TR>
<TR onclick="tClick(1)" align=center>
<TD nowrap align=center height=25 width="170"> <IMG id=titleimg1 src="../imgs/plus.gif" alt="展开" width="9" height="7"></TD>
<TD id=title1 class=collapse align=left width=593><B>WWW</B></TD>
</TR>
<TR id=centent1 class=hide>
<TD width="170"> </TD>
<TD width="145">
<TABLE border=0 cellspacing=2 cellpadding=2 width=67>
<TR>
<TD id=title1 class=collapse align=left width=69><B>AAA</B></TD>
</TR>
<TR>
<TD id=title3 class=collapse align=left width=69><B>BBB</B></TD>
</TR>
<TR>
<TD id=title4 class=collapse align=left width=69><B>CCC</B></TD>
</TR>
<TR><TD height=5 width="34"></TD></TR>
</TABLE>
</TD>
</TR>
</TABLE>
<SCRIPT language=javascript>
<!--
var total = 12;
function tClick(title_id)
{
//text ="hello world!!!"
//document.writeln(text.anchor("text"));
var CurrentImg = document.all('titleimg' + title_id);
var CurrentTD = document.all('title' + title_id);
var CurrentContent = document.all('centent' + title_id);
alert(CurrentTD.classname); ****************
if(CurrentTD.className == 'collapse') //It is collapsed,shound do expand
{
for(var i=1;i<=total-1;i++)
{
if(i != title_id)
{
var objImg = document.all('titleimg' + i);
if (objImg!=null){
objImg.src = '../imgs/plus.gif';
objImg.alt = '展开';
var objContentTable = document.all('centent' + i);
objContentTable.className = 'hide';
}
}
}
CurrentImg.src = '../imgs/minus.gif';
CurrentImg.alt = '折叠';
CurrentContent.className = 'show';
CurrentTD.className = 'expand';
}
else if(CurrentTD.className == 'expand') //It is expanded,shound do collapse
{
CurrentImg.src = '../imgs/plus.gif';
CurrentImg.alt = '展开';
CurrentContent.className = 'hide';
CurrentTD.className = 'collapse';
}
}
-->
</SCRIPT>
</HTML>
在******处IE报“UNDEFINED”错误!!!