演示:http://ASP2004.Net/temp/treemenu/async.ASP
源代碼下載:http://ASP2004.Net/dvbbs/Dispbbs.ASP?boardid=4&ID=89&replyID=375&skin=1
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/Html4/loose.dtd">
<!--#include file="conn.ASP"-->
<Html>
<head>
<meta http-equiv="Content-Type" content="text/Html; charset=gb2312">
<title>http://ASP2004.Net</title>
<link href="style.css" rel="stylesheet" type="text/CSS">
</head>
<body >
<script language="Javascript" src="function.JS"></script>
<script language="Javascript">
var isShow;
var isLoad;
isLoad = new ActiveXObject("Scripting.Dictionary");
//isShow = new ActiveXObject("Scripting.Dictionary");
function exe(id)
{
if (!isLoad.Exists(id))
{
isLoad.add(id,'');
loaddata(id);
}
/*
if(isShow.Exists(id))
{
isShow.Remove(id);
}
else
{
isShow.Add(id,'');
}
*/
if (id>0)
change1('a'+id,'b'+id);
}
function loaddata(id)
{
eval('c'+id).innerHtml = '正在加載。。。';
var xml = new ActiveXObject("Microsoft.XMLHTTP");
XML.open("GET","server.ASP?id="+id,false);
XML.send();
var returnvalue = unescape(XML.ResponseText);
var m = returnvalue.split("#");
var str;
str="<table border='0' cellspacing='0' cellpadding='0'>";
var i=0,len=m.length-1;
for (;i<len;i++)
{
var n = m[i].split("*");
if ( n[0] > 0 )//有子節點
{
var listtype;
if ( i == len-1 )//最後一個
{
str += "<tr colspan='2' onClick=exe('" + n[1] + "');><td id='b" + n[1] + "' class='menu3'>" + n[3] + "</td></tr>";
listtype="list1";
}
else
{
str += "<tr colspan='2' onClick=exe('" + n[1] + "');><td id='b" + n[1] + "' class='menu1'>" + n[3] + "</td></tr>";
listtype="list";
}
str += "<tr id='a" + n[1] + "' style='display:none'><td id='c" + n[1] + "' class='" + listtype + "'></td>";
}
else//葉子節點
{
if ( i == len-1 )//最後一個
{
str += "<tr><td id='b" + n[1] + "' class='file1'><a href='" + n[4] + "' target='_blank'>" + n[3] + "</a></td></tr>";
}
else
{
str += "<tr><td id='b" + n[1] + "' class='file'><a href='" + n[4] + "' target='_blank'>" + n[3] + "</a></td></tr>";
}
}
}
str += "</table>";
eval('c'+id).innerHtml = str;
}
</script>
<a href="menu.ASP">後台管理</a> 異步調用:<br>
<div id="c0"></div>
</body>
</Html>