急急急!JavaScript菜单功能问题

yuanyou 2005-11-16 10:29:06
小弟最近才看JavaScript,写了个导航式菜单,出错 ,无从改起啊 !各位网页大虾救命啊 !如果成功了麻烦把代码全发上了哦!


<html>
<head>
<title>导航菜单</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
var headheight=22;
var bodyheight=202;
var objcount=6;
var step=10;
var moving=false;
function showme(obj1,obj2)
{
if (moving)
return;
moving=true;
for(i=0;i<document.all.tags('td').length;i++)
if (document.all.tags('td')[i].classname.indexof('headtd')==0)
document.all.tags('td')[i].classname = 'headtd1';
obj2.classname = 'headtd2';
moveme(obj1);

}
function moveme(obj)
{
idnumber = parseint(obj.id.substr(4));
objtop = headheight * (idnumber - 1);
objbuttom = bodyheight + headheight * (idnumber - 2);
currenttop = parseint(obj.style.top);
if (currenttop >= objbuttom)
{
if (document.all.tags('div')[i].id=='item'+countid+'body')
{
obj = document.all.tags('div')[i];
objtop = headheight * (countid - 1);
if (countid == idnumber)
{
moveup(obj.objtop,false);
break;

}
else
moveup(obj,objtop,true);
countid++;
}

}
else if ((currenttop >= objtop) && (idnumber < objcount))
{
idnumber++;
countid = objcount;
for (i=document.all.tags('div').length-1;i>=0;i--)
if (document.all.tags('div')[i].id=='item'+countid+'body')
{
obj = document.all.tags('div')[i];
objbuttom = bodyheight + headheight * (countid - 2)
if (countid == idnumber)
{
movedown(obj,objbuttom,false);
break;

}
else
movedown(obj,objbuttom,true);
countid--;

}
}
}

function moveup(obj,objtop,ismove)
{
currenttop = parseint(obj.style.top);
if (currenttop > objtop)
{
obj.style.top = currenttop - step;
settimeout('moveup('+obj.id+','+objtop+','+ismove+')',1)
return;
}
moving = ismove;
}


function movedown(obj,objbuttom,ismove)
{
currenttop = parseint(obj.style.top);
if (currenttop < objbuttom)
{
obj.style.top = currenttop + step;
settimeout('movedown('+obj.id+','+objbuttom+','+ismove+')',1)
return;

}
moving = ismove;


}
</script>
<style type="text/css">
<!--
.headtd1 { background:#eaeaea; border:1px outset; border-color:#ffffff #000000 #000000 #ffffff; cursor:hand; font-size:9pt}
.headtd2 { background:#cccccc; border:1px outset; border-color:#ffffff #000000 #000000 #ffffff; cursor:hand; font-size:9pt}
.bodytd { background:#eeeeee; border:1px outset; border-color:#ffffff #000000 #000000 #ffffff; font-size:9pt}

-->

</style>
</head>

<body>
<div align="center">土匪菜单</div>
<div id="mainboard" style="position:absolute; left:2px; top:2px; width:120px; height:312px; z-index:1; overflow:hidden; background: #eeeeee;">

<div id="item1body" style="position:absolute; left:0; top:0; width:120px; height:202px; z-index:2; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item1head" height="20" class="headtd2" onClick="showme(item1body, this)" align="center">菜单1</td>
</tr>
<tr>
<td class="bodytd" align="center">text</td></tr></table>
</div>


<div id="item2body" style="position:absolute; left:0; top:202; width:120px; height:202px; z-index:3; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item2head" height="20" class="headtd1" onClick="showme(item2body, this)" align="center">菜单2</td>
</tr>
<tr>
<td class="bodytd" align="center">text</td></tr></table>
</div>

<div id="item3body" style="position:absolute; left:0; top:224; width:120px; height:202px; z-index:4; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item3head" height="20" class="headtd1" onClick="showme(item3body, this)" align="center">菜单3</td>
</tr>
<tr>
<td class="bodytd" align="center">text</td></tr></table>
</div>

<div id="item4body" style="position:absolute; left:0; top:246; width:120px; height:202px; z-index:5; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item4head" height="20" class="headtd1" onClick="showme(item4body, this)" align="center">菜单4</td>
</tr>
<tr>
<td class="bodytd" align="center">text</td></tr></table>
</div>

<div id="item5body" style="position:absolute; left:0; top:268; width:120px; height:202px; z-index:6; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item5head" height="20" class="headtd1" onClick="showme(item5body, this)" align="center">菜单5</td>
</tr>
<tr>
<td class="bodytd" align="center">text</td></tr></table>
</div>

<div id="item6body" style="position:absolute; left:0; top:290; width:120px; height:202px; z-index:7; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item6head" height="20" class="headtd1" onClick="showme(item6body, this)" align="center">菜单6</td>
</tr>
<tr>
<td class="bodytd" align="center">text</td></tr></table>
</div>
</div>

</body>
</html>
...全文
109 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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