#22006/2/20 23:29:16
晕了~~大家帮我看看,实现这种结构的树形菜单,
究竟出错在哪里了。
页面代码
-------------------------------------------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style>
<!--
#foldheader{cursor:hand ; font-weight:bold ;
list-style-image:url(fold.gif)}
#foldinglist{list-style-image:url(list.gif)}
BODY{
FONT-FAMILY: 宋体; font-size:9pt; COLOR: #000000;
Margin-left:0; Margin-top:0; Margin-right:0; Margin-bottom:0;
background-image:url(tree_bg.gif);
SCROLLBAR-FACE-COLOR: #EBE2DD; SCROLLBAR-HIGHLIGHT-COLOR: #ECE4D9; SCROLLBAR-SHADOW-COLOR: #A39572; SCROLLBAR-3DLIGHT-COLOR: #ECE4D9; SCROLLBAR-ARROW-COLOR: #876C61; SCROLLBAR-TRACK-COLOR: #F5F2ED; SCROLLBAR-DARKSHADOW-COLOR: #F5F2ED
}
A:link{
COLOR: #745C35; TEXT-DECORATION: NONE;
}
A:visited{
COLOR: #745C35; TEXT-DECORATION: NONE;
}
A:hover{
COLOR: #444444; TEXT-DECORATION: UNDERLINE;
}
A:active{
COLOR: #000000; TEXT-DECORATION: NONE;
}
A.folder:link{
COLOR: #000000; TEXT-DECORATION: NONE;
}
A.folder:visited{
COLOR: #000000; TEXT-DECORATION: NONE;
}
A.folder:hover{
COLOR: #000000; TEXT-DECORATION: UNDERLINE;
}
A.folder:active{
COLOR: #C90000; TEXT-DECORATION: NONE;
}
-->
</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="images/fold.gif"
img2=new Image()
img2.src="images/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(images\open.gif)"
}
else {
nested.style.display="none"
event.srcElement.style.listStyleImage="url(images\fold.gif)"
}
}
}
document.onclick=change
//-->
</script>
<title>无标题文档</title>
</head>
<body>
<ul>
<li id="foldheader"><a href="www.google.com" target="_parent">一级菜单</a></li>
<ul id="foldinglist" style="display:none">
<li id="foldheader"><a href="#" target="_parent">二级菜单</a></li>
<ul id="foldinglist" style="display:none">
<li><a href="#" target="_parent">三级菜单</a></li>
<li><a href="#" target="_parent">三级菜单</a></li>
<ul id="foldinglist" style="display:none">
<li><a href="#" target="_parent">四级菜单</a></li>
<ul id="foldinglist" style="display:none">
<li><a href="#" target="_parent">第5层</a></li>
</ul>
<li><a href="#" target="_parent">对象1</a></li>
<li><a href="#" target="_parent">线索1</a></li>
</ul>
</ul>
<script language="javascript1.2">
<!--
/**
* Get cookie routine by Shelley Powers
* (shelley.powers@ne-dev.com)
*/
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (documents.cookie.length > 0) {
offset = documents.cookie.indexOf(search)
// if cookie exists
if (offset != -1) {
offset += search.length
// set index of beginning of value
end = documents.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1) end = documents.cookie.length;
returnvalue=unescape(documents.cookie.substring(offset, end))
}
}
return returnvalue;
}
if (get_cookie(window.location.pathname) != ''){
var openresults=get_cookie(window.location.pathname).split(" ")
for (i=0 ; i < openresults.length ; i++){
foldinglist[openresults[i]].style.display=''
document.all[foldinglist[openresults[i]].sourceIndex -
1].style.listStyleImage="url(images/open.gif)"
}
}
if (document.all){
var nodelength=foldinglist.length-1
var nodes=new Array(nodelength)
var openones=''
}
function check(){
for (i=0 ; i <= nodelength ; i++){
if (foldinglist[i].style.display=='')
openones=openones + " " + i
}
documents.cookie=window.location.pathname+"="+openones
}
if (document.all)
document.body.onunload=check
//-->
</script>
</body>
</html>
编辑历史:[此帖最近一次被 ameisang 编辑过(编辑时间:2006-02-20 23:35:41)]