日期:2014-05-16  浏览次数:20289 次

点击树型目录的内容打开下一级目录如何实现.
我的树状目录是动态生成的,调用了一个别人写的方法XinitTree(),参数里有一个nodeclick的事件,它的点击事件实现了点击节点能够展开目录树,
可点击内容打不开,我如何写个方法,点击文件夹的时候也能打开目录呢?


------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN "
"http://www.w3.org/TR/html4/loose.dtd ">
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> 无标题文档 </title>

<style>
<!--
#foldheader{cursor:hand ; font-weight:bold ;
list-style-image:url(fold.gif)}
#foldinglist{list-style-image:url(list.gif)}
//-->
</style>
<script language= "JavaScript1.2 ">
<!--
/**
* Based on Folding Menu Tree
* Dynamic Drive (www.dynamicdrive.com)
* For full source code, installation instructions,
* 100 's more DHTML scripts, and Terms Of
* Use, visit dynamicdrive.com
*
* Updated to support arbitrarily nested lists
* by Mark Quinn (mark@robocast.com) November 2nd 1998
*/
var head= "display: ' ' "
img1=new Image()
img1.src= "fold.gif "
img2=new Image()
img2.src= "open.gif "

function change(){
if(!document.all)
return
if (event.srcElement.id== "foldheader ") {
var srcIndex = event.srcElement.sourceIndex
var nested = document.all[srcIndex+1]
if (nested.style.display== "none ") {
nested.style.display= ' '
event.srcElement.style.listStyleImage= "url(open.gif) "
}
else {
nested.style.display= "none "
event.srcElement.style.listStyleImage= "url(fold.gif) "
}
}
}

document.onclick=change

//-->
</script>


</head>

<body>
<ul>
<li id= "foldheader "> News </li>
<ul id= "foldinglist " style= "display:none ">
<li> <a href= "http://www.cnn.com "> CNN </a> </li>
<li> <a href= "http://www.abcnews.com "> ABC News </a> </li>
<li> <a href= "http://www.vancouversun.com "> Vancouver Sun </a> </li>
</ul>
<li id= "foldheader "> Games </li>
<ul id= "foldinglist " style= "display:none ">
<li> <a href= "http://www.gamespot.com "> GameSpot </a> </li>
<li> <a href= "http://www.happypuppy.com "> Happy Puppy </a> </li>
<li> <a href= "http://www.gamecenter.com "> Game Center </a> </li>
</ul>

<li id= "foldheader "> Software </li>
<ul id= "foldinglist " style= "display:none ">
<li> <a href= "http://www.download.com "> outer 1 </a> </li>
<li> <a href= "http://www.hotfiles.com "> outer 2 </a> </li>
<li id= "foldheader "> Nested </li>
<ul id= "foldinglist " style= "display:none ">
<li> <a href= "http://www.windows95.com "> nested 1 </a> </li>
<li> <a href= "http://www.shareware.com "> nested 2 </a> </li>
</ul>
<li> <a href= "http://www.windows95.com "> outer 3 &