鼠标经过改成点击?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>
<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>
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>
这里的代码有问题,注意onmouseover和onmouseout事件是是不可分开的