主题:超级难题啊,高的帮帮忙
syqnet
[专家分:70] 发布于 2006-05-07 10:15:00
类似这个网站的树形目录怎么实现的
http://202.119.208.81/CourseLib/271/Html/Root/Index.htm
会做的说说思想也行,有代码更好。急着用啊。
回复列表 (共1个回复)
沙发
yiyi735 [专家分:680] 发布于 2006-05-11 11:15:00
用javascript+css做的树状目录 在IE下了用NETSCAPE下只能全展开,谁能解决这个问题呢?
------
将下面代码保存到一个HTML里就行了
<html>
<head>
<script language="JavaScript">
var NS4 = false;
var IE4 = false;
var ver4 = false;
var thename=navigator.appName;
result=thename.indexOf("Microsoft Internet Explorer");
if(result!=-1){
IE4=true;
}else{
IE4=false;
}
if(NS4||IE4){
ver4=true;
}else{
ver4=false;
}
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}")
}
write("</STYLE>");
}
}
function initIt(){
if (!ver4) return;
if (IE4){
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();
}
}
</script>
</head>
<body onload=initIt()>
<table border="1" align="center" width="60%">
<tr>
<td width="70%"">xxxx</td>
<td>vvvv</td>
</tr>
<tr>
<td>
<div id="KB1Parent" class="parent">
<a href="" onclick="expandIt('KB1');return false;">分类一</a>
</div>
<div id="KB1Child" class="child">
1<br>
2<br>
3
</div>
<div id="KB2Parent" class="parent">
<a href="" onclick="expandIt('KB2');return false;">分类二</a>
</div>
<div id="KB2Child" class="child">
1<br>
2<br>
3
</div>
<div id="KB3Parent" class="parent">
<a href="" onclick="expandIt('KB3');return false;">分类三</a>
</div>
<div id="KB3Child" class="child">
1<br>
2<br>
3
</div>
</td>
<td>
yyyy
</td>
</tr>
</table>
</body>
</html>
我来回复