Forum Moderators: open

Message Too Old, No Replies

clear timeout problems

         

hOtTiGeR123

1:57 pm on Dec 12, 2009 (gmt 0)

10+ Year Member



Hi, I have the following code but the clear timeout doesn't work and I can't understand why, does anyone have any ideas? (Using the Prototype framework)

Thanks

function foo() {
$("navigation").observe('mouseover',
function (event) {
clearTimeout(bar);
}
).observe('mouseout',
function (event) {
setTimeout(bar, 1000);
}
);
}

function bar() {
alert("hi");
}

Fotiman

3:23 pm on Dec 12, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



setTimeout returns a value that you can use if you want to cancel the timeout. So you would need to store that value in a variable, and then clearTimeout takes that value as a parameter.

var t = setTimeout(bar, 1000);
clearTimeout(t);