对于js这种调试很困难的语言我真是很头疼,实现一个树状菜单也费了好大力气,干脆我把枝叶都去掉只留了个光杆,不能再去了为止.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript>
var whichOpen="";
function menuShow(obj,obj2)
{
if(obj.style.pixelHeight<80)
{
obj.style.pixelHeight+=4;
obj.style.display='block';
myObj=obj;
myObj2=obj2;
setTimeout('menuShow(myObj,myObj2)');
}
}
function menuHide(obj,obj2)
{
if(obj.style.pixelHeight>0)
{
obj.style.display='none';
obj.style.pixelHeight-=4;
myObj=obj;
myObj2=obj2;
setTimeout('menuHide(myObj,myObj2)');
}
}
function menuChange(obj,obj2)
{
if(obj.style.pixelHeight)
{
menuHide(obj,obj2);
whichOpen='';
}
else
{
menuShow(obj,obj2);
whichOpen=obj2;
}
}
</script>
</head>
<body >
<table width=158 border="0" align=center cellpadding=0 cellspacing=0>
<tr style="cursor:hand;">
<td height=25 id=id1 onClick="menuChange(me,id1);" >
<span>菜单选项</span>
</td>
</tr>
<tr>
<td>
<div style="width:158;height:0;filter:alpha(Opacity=0);display:none;" id=me>
<table cellpadding=0 cellspacing=0 align=center width=135 style="position:relative;top:10px;">
<tr>
<td height=20>
<a href="#">菜单1</a>
</td>
</tr>
<tr>
<td height=20>
<a href="#">菜单2</a>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</body>
</html>