您的位置:首页 > Web前端 > JavaScript

收缩展开的竖直菜单(利用JS+CSS实现_网页代码站(www.webdm.cn)

2010-12-14 11:30 1316 查看
<html>
<head>
<title>收缩展开的竖直菜单(利用JS+CSS实现_网页代码站(www.webdm.cn)</title>
<script language="JavaScript">
NS4 = (document.layers) ? 1 : 0;
IE4 = (document.all) ? 1 : 0;
ver4 = (NS4 || IE4) ? 1 : 0;
if (ver4) {
with (document) {
write("<STYLE TYPE='text/css'>");
if (NS4) {
write(".parent {position:absolute; visibility:visible}");
write(".child {position:absolute; visibility:visible}");
write(".regular {position:absolute; visibility:visible}")
}
else {
write(".child {display:none}")
}
write("</STYLE>");
}
}
function arrange() {
nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;
for (i=firstInd+1; i<document.layers.length; i++) {
whichele = document.layers[i];
if (whichele.visibility != "hide") {
whichele.pageY = nextY;
nextY += whichele.document.height;
}
}
}
function initIt(){
if (!ver4) return;
if (NS4) {
for (i=0; i<document.layers.length; i++) {
whichele = document.layers[i];
if (whichele.id.indexOf("Child") != -1) whichele.visibility = "hide";
}
arrange();
}
else {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
whichele = divColl(i);
if (whichele.className == "child") whichele.style.display = "none";
}
}
}
function expandIt(ele) {
if (!ver4) return;
if (IE4) {
whichele = eval(ele + "Child");
if (whichele.style.display == "none") {
whichele.style.display = "block";
}
else {
whichele.style.display = "none";
}
}
else {
whichele = eval("document." + ele + "Child");
if (whichele.visibility == "hide") {
whichele.visibility = "show";
}
else {
whichele.visibility = "hide";
}
arrange();
}
}
onload = initIt;
</script>
</head>
<body>
<div id="menuParent" class="parent">    <a href="#" onClick="expandIt('menu'); return false" >第一菜单</a></div>
<div id="menuChild" class="child">     <a href="http://www.webdm.cn" target="_blank" >CSS菜单</a><br>
     <a href="/" target="_blank" >网页特效</a><br>
     <a href="/" target="_blank" >电子书籍</a></div>
<div id="Menu2Parent" class="parent">    <a href="#" onClick="expandIt('Menu2'); return false" >第二菜单</a></div>
<div id="Menu2Child" class="child">     <a href="/" target="_blank" >源码下载</a><br>
     <a href="/" target="_blank" >站长工具</a><br>
     <a href="/" target="_blank" >教程天地</a></div>
<div id="Menu3Parent" class="parent">    <a href="#" onClick="expandIt('Menu3'); return false" >第三菜单</a></div>
<div id="Menu3Child" class="child">      <a href="#" target="_blank" >自定义一</a><br>
     <a href="#" target="_blank" >自定义二</a><br>
     <a href="#" target="_blank" >自定义三</a></div>
</body>
</html>
<a href="http://www.webdm.cn">网页代码站</a> - 最专业的代码下载网站 - 致力为中国站长提供有质量的代码!


文章来自:http://www.webdm.cn/webcode/f7adc0f5-5342-4bb9-b1dd-e2c6659cedf7.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: