<!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=utf-8" />
<meta name="Keywords" content="电影|视频"/>
<meta name="Description" content="电影|视频"/>
<title>下拉列表</title>
<style>
#menu a {color:#D2E3EA; font-weight:bold;font-size:20px; }
#menu ul{}
#menu li {  padding:0px ; text-align:center;}
#menu li ul li{ margin:0px auto;}
#menu li ul li li{background:none; line-height:20px; background:none;}
#menu strong{ color:#696;}
#menu.dyn li ul{ display:none;}
#menu.dyn li ul.show{ display:block;}
#menu.dyn li{ line-height:42px; margin:0px auto;  background:url("../images/blue/nlistbg.jpg") no-repeat center top;}
#menu.dyn li li{ line-height:35px;  background:url("../images/blue/nlistbg2.jpg") no-repeat center top;}
#menu.dyn li li li{ line-height:30px;}
#menu.dyn li li li a{color:#036AAC;}
#menu.dyn li.parent{}
#menu.dyn li.open{}
#menu.dyn li.open ul{ border:#8ACEEB 1px solid;}
#menu.dyn li.open li{}
#menu.dyn li.open li li{background:none;}
</style>
</head><body><!-- 加载列表 -->
<script type="text/javascript">
DOMhelp = {
debugWindowId: 'DOMhelpdebug',
init: function() {
if (!document.getElementById || !document.createTextNode) { return; }
},
addLink: function(o, to) {
//var tempObj = document.createElement('a');
//tempObj.appendChild(document.createTextNode(txt));
o.setAttribute('href', to);
//return tempObj;
},
/* helper methods */getTarget: function(e) {
var target = window.event ? window.event.srcElement : e ? e.target : null;
if (!target) { return false; }
while (target.nodeType != 1 && target.nodeName.toLowerCase() != 'body') {
target = target.parentNode;
}
return target;
},
cancelClick: function(e) {
if (window.event) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}
if (e && e.stopPropagation && e.preventDefault) {
e.stopPropagation();
e.preventDefault();
}
},
addEvent: function(elm, evType, fn, useCapture) {
if (elm.addEventListener) {
elm.addEventListener(evType, fn, useCapture);
return true;
} else if (elm.attachEvent) {
var r = elm.attachEvent('on' + evType, fn);
return r;
} else {
elm['on' + evType] = fn;
}
},
cssjs: function(a, o, c1, c2) {
switch (a) {
case 'swap':
o.className = !DOMhelp.cssjs('check', o, c1) ? o.className.replace(c2, c1) : o.className.replace(c1, c2);
break;
case 'add':
if (!DOMhelp.cssjs('check', o, c1)) { o.className += o.className ? ' ' + c1 : c1; }
break;
case 'remove':
var rep = o.className.match(' ' + c1) ? ' ' + c1 : c1;
o.className = o.className.replace(rep, '');
break;
case 'check':
var found = false;
var temparray = o.className.split(' ');
for (var i = 0; i < temparray.length; i++) {
if (temparray[i] == c1) { found = true; }
}
return found;
break;
}
},
safariClickFix: function() {
return false;
}
}
DOMhelp.addEvent(window, 'load', DOMhelp.init, false);
</script>
<script type="text/javascript">
<!--
    sn = {
        dynamicClass: 'dyn',
        showClass: 'show',
        parentClass: 'parent',
        openClass: 'open',
        navID: 'menu',
        init: function() {
            var triggerLink;
            if (!document.getElementById || !document.createTextNode) { return; }
            var nav = document.getElementById(sn.navID);
            if (!nav) { return; }
            DOMhelp.cssjs('add', nav, sn.dynamicClass);
            var nested = nav.getElementsByTagName('ul');
            for (var i = 0; i < nested.length; i++) {
                triggerLink = nested[i].parentNode.getElementsByTagName('a')[0];
    //alert(triggerLink);
                DOMhelp.cssjs('add', triggerLink.parentNode, sn.parentClass);
                DOMhelp.addEvent(triggerLink, 'click', sn.changeSection, false);
    
                triggerLink.onclick = DOMhelp.safariClickFix;
    DOMhelp.addLink(triggerLink.parentNode,triggerLink);
    //alert("==============");
                if (nested[i].parentNode.getElementsByTagName('strong').length > 0) {
                    DOMhelp.cssjs('add', triggerLink.parentNode, sn.openClass);
                    DOMhelp.cssjs('add', nested[i], sn.showClass);
                }
            }
        },
        changeSection: function(e) {
            var t = DOMhelp.getTarget(e);
   //alert(t);
            var firstList = t.parentNode.getElementsByTagName('ul')[0];
            if (DOMhelp.cssjs('check', firstList, sn.showClass)) {
                DOMhelp.cssjs('remove', firstList, sn.showClass)
                DOMhelp.cssjs('swap', t.parentNode, sn.openClass, sn.parentClass);
            } else {
                DOMhelp.cssjs('add', firstList, sn.showClass)
                DOMhelp.cssjs('swap', t.parentNode, sn.openClass, sn.parentClass);
            }
            DOMhelp.cancelClick(e);
        }
    }
    DOMhelp.addEvent(window, 'load', sn.init, false);-->
</script>
<div class="menu">
 <ul id="menu">
  <li><a href="javascript:void(0)">二级栏目1</a>
<ul><li><a href="www.baidu.com" target="main">三级栏目1</a>
<ul><li><a href="www.baidu.com" target="main">四级栏目1</a>
<ul>
<li class="tlist"><a href="www.baidu.com" target="main" title="cesy">05.17cesy</a> </li>
<li class="tlist"><a href="www.baidu.com" target="main" title="wwasd">05.16wwasd</a> </li>
<li class="tlist"><a href="www.baidu.com" target="main" title="香格里拉 02">05.11香格里拉 02</a> </li>
<li class="tlist"><a href="www.baidu.com" target="main" title="香格里拉 第1集">05.10香格里拉 第1集</a> </li>
</ul>
</li>
<li><a href="www.baidu.com" target="main">四级栏目2</a>
<ul><li class="tlist"><a href="www.baidu.com" target="main" title="ttttttttttt">05.17ttttttttttt</a> </li></ul>
</li><li><a href="www.baidu.com" target="main">四级栏目3</a>
</li><li><a href="www.baidu.com" target="main">四级栏目4</a>
</li><li><a href="www.baidu.com" target="main">四级栏目5</a>
</li><li><a href="www.baidu.com" target="main">四级栏目6</a>
</li><li><a href="www.baidu.com" target="main">四级栏目7</a>
</li><li><a href="www.baidu.com" target="main">四级栏目8</a>
</li><li><a href="www.baidu.com" target="main">四级栏目9</a>
</li>
</ul>
</li><li><a href="www.baidu.com" target="main">三级栏目2</a>
</li><li><a href="www.baidu.com" target="main">三级栏目3</a>
</li><li><a href="www.baidu.com" target="main">三级栏目4</a>
</li><li><a href="www.baidu.com" target="main">三级栏目5</a>
</li><li><a href="www.baidu.com" target="main">三级栏目6</a>
</li><li><a href="www.baidu.com" target="main">三级栏目7</a>
</li><li><a href="www.baidu.com" target="main">三级栏目8</a>
</li><li><a href="www.baidu.com" target="main">三级栏目9</a>
</li></ul></li><li><a href="javascript:void(0)">二级栏目2</a>
</li><li><a href="javascript:void(0)">二级栏目3</a>
</li><li><a href="javascript:void(0)">二级栏目4</a>
</li><li><a href="javascript:void(0)">二级栏目5</a>
</li><li><a href="javascript:void(0)">二级栏目6</a>
</li><li><a href="javascript:void(0)">二级栏目7</a>
</li><li><a href="javascript:void(0)">二级栏目8</a>
</li><li><a href="javascript:void(0)">二级栏目9</a>
</li>
 </ul>
</div></body>
</html>这是段实现下拉列表的代码,但是中间栏目无法链接了,比如【四级栏目1】,只有下拉效果,链接不了,请帮忙把链接实现了

解决方案 »

  1.   


                    triggerLink = nested[i].parentNode.getElementsByTagName('a')[0];
                    //alert(triggerLink);
                    DOMhelp.cssjs('add', triggerLink.parentNode, sn.parentClass);
                    DOMhelp.addEvent(triggerLink, 'click', sn.changeSection, false);这里处理的时候出现问题了吧!~  不知道该怎么修改,但是感觉应该是这里的问题