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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone help me add a timeout to this script?

Status
Not open for further replies.

JSDNUK

Programmer
Feb 13, 2006
21
GB
Basically all I need to do is add a timeout to the onmouseout function, but have thus far had no luck :(

e.g. the_timeout = setTimeout(this.className=this.className.replace(new RegExp(" sfhover\\b"), ""), 1000);

See the full script below. Many Thanks... again!!

sfHover = function() {
var sfEls = document.getElementById("Nav_A").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls.onmouseover=function() {
this.className+=" sfhover";
}
sfEls.onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
 
I don't understand how can you add a timeout to a mouse movement. Do you mean doing something if the mouse is still over a component?

Cheers,
Dian
 
I was hoping that I might be able to replace the line (8) of code...

this.className=this.ClassName.replace(New RegExp( " sfhover\\b"), "");

With something along the lines of...

the_timeout = setTimeout(this.className=this.className.replace(new RegExp(" sfhover\\b"), ""), 1000);

Do you know if something like this would be possible??

Many Thanks...
 
Ok, i'm with you now... Sorry about that.

This script controls a CSS/List based 2nd Level Navigation for IE. What i'm trying to do is add a delay on mouseout in the hope that this will make my site a little easier to use (apparently).
 
Unfortunately I am not getting any script errors. The script behaviour, however, is failing completely. Basically, the 2nd level of navigation appears but either disappears on mouseout straight away or remains on screen permanently depending on which piece of incorrect code I use at the time...

Any ideas on how I might get around this?

Thanks,

David
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top