鼠标经过改成点击?onmouseover改成onclick不管用,大虾指点下 !!
<script type=text/javascript>
startList = function() {
if (document.all&&document.getElementById) {
dropmenuRoot = document.getElementById("dropmenu");
for (i=0; i<dropmenuRoot.childNodes.length; i++) {
node = dropmenuRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
for(j=0;j<this.childNodes.length;j++){
if (this.childNodes[j].nodeName=="UL"){
if (this.childNodes[j].childNodes[0].nodeName=="LI"){
if (this.offsetLeft+this.childNodes[j].childNodes.length*this.childNodes[j].childNodes[0].offsetWidth-dropmenuRoot.offsetLeft>dropmenuRoot.offsetWidth){
len =this.offsetLeft+len-dropmenuRoot.offsetLeft-dropmenuRoot.offsetWidth;
(len>this.offsetLeft-dropmenuRoot.offsetLeft) ? this.childNodes[j].style.marginLeft=-(this.offsetLeft-dropmenuRoot.offsetLeft) : this.childNodes[j].style.marginLeft=-len+"px";
}
}
}
}
}node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
</script>

解决方案 »

  1.   

    <script type=text/javascript>
    startList = function() {
    if (document.all&&document.getElementById) {
    dropmenuRoot = document.getElementById("dropmenu");
    for (i=0; i<dropmenuRoot.childNodes.length; i++) {
    node = dropmenuRoot.childNodes[i];
    if (node.nodeName=="LI") {
    node.onclick=function() {
    this.className+=" over";
    for(j=0;j<this.childNodes.length;j++){
    if (this.childNodes[j].nodeName=="UL"){
    if (this.childNodes[j].childNodes[0].nodeName=="LI"){
    if (this.offsetLeft+this.childNodes[j].childNodes.length*this.childNodes[j].childNodes[0].offsetWidth-dropmenuRoot.offsetLeft>dropmenuRoot.offsetWidth){
    len =this.offsetLeft+len-dropmenuRoot.offsetLeft-dropmenuRoot.offsetWidth;
    (len>this.offsetLeft-dropmenuRoot.offsetLeft) ? this.childNodes[j].style.marginLeft=-(this.offsetLeft-dropmenuRoot.offsetLeft) : this.childNodes[j].style.marginLeft=-len+"px";
    }
    }
    }
    }
    }node.onmouseout=function() {
    this.className=this.className.replace(" over", "");
    }
    }
    }
    }
    }
    window.onload=startList;
    </script>
      

  2.   

    大哥,你改成onclick ,那onmouseout是干啥用的?人家配对使用好不?没onmouseover哪有onmouseout?
      

  3.   


    这里的代码有问题,注意onmouseover和onmouseout事件是是不可分开的
      

  4.   

    有必要一起使用吗?你单独out不起作用?太形而上学!