Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting Delay

Status
Not open for further replies.

WebRic

Technical User
Sep 21, 2004
95
0
0
GB
Hi all,

I have some menu script that is misfiring. For some reason my onmouseout event seems to fire occasionaly when I roll onto the next item in my list.

I was thinking an easy way round this would be to put a delay on the onmouseout event:

Code:
sli[x].onmouseout = function() { this.className = this.className.replace( " over", "" ); }

However, I can't seem to get it to work. Here's the code:

Code:
function showSubMenu(a) {
    var ul = a.parentNode.getElementsByTagName("ul")[0];
    a.className = ( a.className.indexOf(" selected")>-1 ) ? a.className.split(" selected")[0] : a.className + " selected";
    ul.className = ( ul.className.indexOf(" active")>-1 ) ? ul.className.split(" active")[0] : ul.className + " active";
    return false;
}

function attachEvents() {
    var l = document.getElementById("nav").childNodes;
    for ( var i = 0; i < l.length; i++ ) {
        if ( l[i].nodeName == "LI" && hasChildList(l[i]) ) {
            var a = l[i].getElementsByTagName("a")[0];
            a.onclick = function() { return showSubMenu(this); };
            var sl = l[i].childNodes;
            for ( var y = 0; y < sl.length; y++ ) {
                if ( sl[y].nodeName == "UL" && hasChildList(sl[y]) ) {
                    var sli = sl[y].childNodes;
                    for ( var x = 0; x < sli.length; x++ ) {
                        if ( sli[x].nodeName == "LI" && document.all ) {
                            sli[x].onmouseover = function() { this.className += " over"; }
                            sli[x].onmouseout = function() { this.className = this.className.replace( " over", "" ); }
                        }
                    }
                } 
            }
        }
    }
}

function hasChildList(o) {
    return o.getElementsByTagName("ul").length > 0;
}

Does anyone know what I need to do to get this working?
Thanks,

Richard
 
For some reason my onmouseout event seems to fire occasionaly when I roll onto the next item in my list.

Do you mean when you roll off of one item and onto the next? If so, I would expect it to fire all of the time.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
It was only happening on some of the drop downs. Managed to sort it with a css hack though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top