站内搜索: 请输入搜索关键词

当前页面: 开发资料首页Javascript 专题经典的导航二级式导航菜单增强版,不看不知道!!

经典的导航二级式导航菜单增强版,不看不知道!!

摘要: 经典的导航二级式导航菜单增强版,不看不知道!!



<head>




</head>
<body vlink=#6772CD link='#6772CD'>

<td class=menu onmouseover="movese('进入下载中心|编程工具|电子教程|编程素材|Lshdic2002配套工具','download.asp|download.asp?screen=工具软件&page=1|download.asp?screen=电子教程&page=1|download.asp?screen=编程素材&page=1|download.asp?screen=LD配套工具&page=1')" 下载中心
</td>
<td class=menu onmouseover="movese('进入网页编辑中心|下载编辑网页v2版','editweb.asp|download2.asp?id=48')" 编辑网页
</td>
<td class=menu onmouseover="movese('进入程序编辑中心|下载编写程序v2版','editdhtml.asp|download2.asp?id=92',1000)" 编写程序
</td>
<td class=menu align=center title='进行注册,领取Lshdic200X软件序列号的地方' style='font-size:13px' Lshdic
</td>
<td class=menu onmouseover="movese('查看客户所有留言|签写新留言','bbs2.asp|bbs2fatie.asp')" goto='bbs2.asp'>留言我们
</td>
<td class=menu goto='friendall.asp'>网友中心
</td>
<td class=menu align=center goto='bbs/'>技术论坛
</td></tr></table>

<script>
var cleartime=1
function movese(menustr,menuhref){ //一级菜单的显示函数,menustr=菜单要显示的文本,menuhref=菜单文本对应的网址
happydiv.style.display=''; //首先显示的一级菜单
happydiv2.style.display='none'; //其次将以显示的二级菜单关闭
if(cleartime!=1)clearTimeout(cleartime) //触发此函数通常是在mouseover时,因此取消"定时关闭菜单"的定时器
happydiv.style.posLeft=menutd.offsetLeft+event.srcElement.offsetLeft; //一级菜单绝对位置"左"定位
happydiv.style.posTop=menutd.offsetTop+menutd.offsetHeight //一级菜单绝对位置"上"定位
for(i=0;happydiv.rows.length;i++)happydiv.deleteRow() //清除菜单中以有的TD表格数据
str1=menustr.split('|');str2=menuhref.split('|') //将menustr以"|"号分割为数组
for(i=0;itdstr=happydiv.insertRow().insertCell() //首先在一级菜单中查入一个<tr><td></td></tr>
if(str1[i].indexOf('**')==-1){ //如果是不构成显示二级菜单的数据,以**做判断
if(str1[i]!="-")tdstr.innerHTML=""+str1[i]+"";else tdstr.innerHTML="


"
}else{ //如果是能构成二级菜单的数据则...
str3=str1[i].split('**') //开始构件二级菜单驱动的显示字符
tdstr.innerHTML="/g,"lshdicstr3")+"')>"+str3[0]+" →" //MOVEOVER时调用二级菜单显示函数MOVESE2,replace是将指定网址中的特殊字符替换为预定字符
}}
cleartime=setTimeout('happydiv.style.display="none";happydiv2.style.display="none"',2000) //一切完毕后加上定时关闭菜单,可选
}
function movese2(menustr2,menuhref2){ //二级菜单的显示函数,menustr2=菜单要显示的文本,menuhref=菜单文本对应的网址
happydiv2.style.display=''; //第一步自然是先显示二级菜单的容器表格
if(cleartime!=1)clearTimeout(cleartime) //第二步自然是清除定时器关闭的设置
happydiv2.style.posLeft=happydiv.offsetLeft+happydiv.offsetWidth; //二级菜单定位"左"
temptop1=event.srcElement.parentElement.parentElement
happydiv2.style.posTop=happydiv.offsetTop+(temptop1.offsetHeight*temptop1.rowIndex) //二级菜单定位"上",根据一级菜单中单个TD的高度*第几个计算
for(i=0;happydiv2.rows.length;i++)happydiv2.deleteRow() //定位完毕,开始显示数据,首先要清除以显示的TD
str3=menustr2.split('**');str4=menuhref2.split('**') //然后分解构成二级菜单的数据
for(i=1;itdstr2=happydiv2.insertRow().insertCell() //在二级菜单中插入<tr><td></td></tr>
tdstr2.innerHTML="')+"'>"+str3[i]+"" //设定具体显示的数据,replace将预定字符替换过来
}
cleartime=setTimeout('happydiv.style.display="none";happydiv2.style.display="none"',2000) //一切完毕后加上定时关闭菜单,可选
}
function over1(){ //一,二级菜单中MOVEOVER事件时使用本函数定义菜单效果
if(event.srcElement.tagName=="TD"){event.srcElement.bgColor='eeeeee';event.srcElement.style.borderTop='1 solid';
event.srcElement.style.borderBottom='1 solid'}else if(event.srcElement.tagName=="FONT"||event.srcElement.tagName=="A"){
event.srcElement.parentElement.bgColor='eeeeee';event.srcElement.parentElement.style.borderTop='1 solid';
event.srcElement.parentElement.style.borderBottom='1 solid'}
}
function out1(){ //一,二级菜单中MOVEOUT事件时使用本函数定义菜单效果
if(event.srcElement.tagName=="TD"){event.srcElement.bgColor='';event.srcElement.style.borderTop='';
event.srcElement.style.borderBottom=''
}else if(event.srcElement.tagName=="FONT"||event.srcElement.tagName=="A"){event.srcElement.parentElement.bgColor='';
event.srcElement.parentElement.style.borderTop='';event.srcElement.parentElement.style.borderBottom=''}
}
function click1(){ //一,二级菜单时CLICK单击事件时使用本函数转到指定网址
if(event.srcElement.tagName=="TD")location.href=event.srcElement.all.tags('A')(0).href
}
function over2(){ //基本的HTML导航栏在MOUSEOVER时使用本函数,设定背景,并清除定时关闭
if(event.srcElement.tagName=="TD"){event.srcElement.bgColor='white';if(cleartime!=1)clearTimeout(cleartime)}
}
function out2(){ //基本的HTML导航栏在MOUSEOUT时使用本函数,设定背景,并加上定时关闭菜单的效果
if(event.srcElement.tagName=="TD"){event.srcElement.bgColor='';
cleartime=setTimeout('happydiv.style.display="none";happydiv2.style.display="none"',500)}
}
function click2(){ //基本的HTML导航栏在CLICK单击时转到的网址,目标网址使用自定义的HTML属性GOTO做目标
location.href=event.srcElement.goto
}
function document.onclick(){ //页面单击时关闭所有菜单
happydiv.style.display='none';happydiv2.style.display='none'
}
</script>
<table id=happydiv style='position:absolute;z-index:5;display:none;cursor:hand;border-top:0;border-bottom:0'onmouseover="over1();clearTimeout(cleartime)"
onmouseout="out1();temp1='none';cleartime=setTimeout('happydiv.style.display=temp1;happydiv2.style.display=temp1',500)"
onclick=click1()>
<tr><td></td></tr>
</table>

</td> </tr> <tr> <td vAlign=top align=left height="100%">
↑返回目录
前一篇: 经典的导航二级式导航菜单完整程序及中文注释,强力推荐
后一篇: vbscript和javascript互相调用方法