动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
   .Net → 阅读文章

 三层动态下来菜单的例子,供大家参考

作者来源: 
阅读 数 113 人次 , 2006-4-26 9:51:00 


写了一个三层动态读取文件夹的下拉菜单的例子,供大家参考!
<%
'得到文件夹路径。注意设置文件名字
urlpath=server.mappath("\book")
set fsoBrowse=CreateObject("Scripting.FileSystemObject")

'设置文件夹路径
if Request("path")="" then
lpath=urlpath&"\"
else
lpath=Request("path")&"\"
end if
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv=PRAGMA CONTENT=NO-CACHE>
<title>中国国际航空公司</title>
<link rel="stylesheet" href="news.css">

<script language="JavaScript1.2">
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 getIndex(el) {
ind = null;
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id == el) {
ind = i;
break;
}
}
return ind;
}

function arrange() {
nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;
for (i=firstInd+1; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.visibility != "hide") {
whichEl.pageY = nextY;
nextY += whichEl.document.height;
}
}
}

function initIt(){
if (!ver4) return;
if (NS4) {
for (i=0; i<document.layers.length; i++) {
whichEl = document.layers[i];
if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
}
arrange();
}
else {
divColl = document.all.tags("DIV");
for (i=0; i<divColl.length; i++) {
whichEl = divColl(i);
if (whichEl.className == "child") whichEl.style.display = "none";
}
}
}

function expandIt(el) {
if (!ver4) return;
if (IE4) {
whichEl = eval(el + "Child");
if (whichEl.style.display == "none") {
whichEl.style.display = "block";
}
else {
whichEl.style.display = "none";
}
}
else {
whichEl = eval("document." + el + "Child");
if (whichEl.visibility == "hide") {
whichEl.visibility = "show";
}
else {
whichEl.visibility = "hide";
}
arrange();
}
}

onload = initIt;

</script>

</head>
<body bgcolor="#ffffff" topmargin="0" leftmargin="0">
<table width="248" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>
<%
'处理第一层文件目录
dim theFolder,theSubFolders
if fsoBrowse.FolderExists(lpath)then
Set theFolder=fsoBrowse.GetFolder(lpath)
Set theSubFolders=theFolder.SubFolders

'循环输出第一层文件
i=1
For Each x In theSubFolders
k="KB"&i
Parent=k&"Parent"
i=i+1
%>
<div id="<%=Parent%>" class="parent"> <a href="#" onClick="expandIt('<%=k%>'); return false"><img alt=三层动态下来菜单的例子,供大家参考 src="i_option.gif" width="20" height="16" border="0"><%=x.Name%></a></div>
<%'处理第二层文件
onepath=lpath&x.Name&"\"
if fsoBrowse.FolderExists(onepath) then
Set ChildtheFolder=fsoBrowse.GetFolder(onepath)
Set ChildtheSubFolders=ChildtheFolder.SubFolders
Child=k&"Child"
%>
<div id="<%=Child%>" class="child">
<%'循环输出第二层文件
m=1
For Each y In ChildtheSubFolders
k="KB"&i&m
m=m+1
%>
&nbsp;&nbsp;&nbsp;<img alt=三层动态下来菜单的例子,供大家参考 src="filebox.gif" width="19" height="13"><a href="#" onClick="expandIt('<%=k%>'); return false"><%=y.Name%></a><br>
<%
'处理第三层文件
twopath=onepath&y.Name&"\"
if fsoBrowse.FolderExists(twopath) then
Set gtheFolder=fsoBrowse.GetFolder(twopath)
Set gtheSubFolders=gtheFolder.SubFolders

Child=k&"Child"
%>
<div id="<%=Child%>" class="child">
<%
'循环输出第三层文件
For Each z In gtheSubFolders
%>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <img alt=三层动态下来菜单的例子,供大家参考 src="filebox.gif" width="19" height="13"><%=z.Name%><br>
<%
Next
%>
</div>
<%
end if
%>
<%
Next
%>
</div>
<%
end if
%>
<%
Next
end if
%>
</td>
</tr>
</table>
</body>
</html>

  
 
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:form文本域的通用校验函数
· 下一篇:内嵌播放器,支持real,media,quicktime,flash
· 转换字符串带有http://的超级链接字符串为真正的超级链接
· 深入讲解 ASP+ 验证(一)
· C#,微软.NET战略中的重要棋子
· 用Asp.net实现简单的文字水印
· ASP.NET实现用户在线检测的类源码


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077