js中树菜单代码不对
我要做的一共4个树菜单,但是代码总是不对,菜单可以显示,但是点击时显示不错下面的子菜单!代码如下:
<HTML>
<HEAD>
<TITLE> 分层菜单 </TITLE>
</HEAD>
<BODY bgcolor= "#fef4d2 " >
<br> <br>
<center>
<h2> 菜单导航篇--分层菜单 </h2>
<hr width=300>
<br>
<!-- 案例代码1开始 -->
<script language=JavaScript>
<!-- [Step1]: 这里可以设置图形标志的名称 -->
var exImg=new Image(); exImg.src= 'picture001.jpg '
var unImg=new Image(); unImg.src= 'Picture002.jpg '
var stayFolded=false
function init(){
oTop=new Array()
oTop[0]=new makeMenu( 'divTop1 ', 'divCont ')
oTop[1]=new makeMenu( 'divTop2 ', 'divCont ')
oTop[2]=new makeMenu( 'divTop3 ', 'divCont ')
oSub=new Array()
oSub[0]=new makeMenu( 'divSub1 ', 'divCont.document.divTop1 ')
oSub[1]=new makeMenu( 'divSub2 ', 'divCont.document.divTop2 ')
oSub[2]=new makeMenu( 'divSub3 ', 'divCont.document.divTop3 ')
for(i=0;i <oSub.length;i++){ oSub[i].hideIt() }
for(i=1;i <oTop.length;i++){ oTop[i].moveIt(0,oTop[i-1].y+oTop[i-1].height) }
}
function makeMenu(obj,nest){
nest=(!nest) ? ' ': 'document. '+nest+ '. '
this.css = ((document.layers) ? 1:0) ? eval(nest+ 'document. '+obj):eval( 'document.all. '+obj+ '.style ') ;
this.ref=((document.layers) ? 1:0) ? eval(nest+ 'document. '+obj+ '.document '):eval( 'document ');
this.height=(document.layers) ? 1:0?this.ref.height:eval(obj+ '.offsetHeight ')
this.x=((document.layers) ? 1:0)? this.css.left:this.css.pixelLeft;
this.y=((document.layers) ? 1:0)? this.css.top:this.css.pixelTop;
this.hideIt=b_hideIt; this.showIt=b_showIt; this.vis=b_vis; this.moveIt=b_moveIt
return this
}
function b_showIt(){this.css.visibility= "visible "}
function b_hideIt(){this.css.visibility= "hidden "