...

View Full Version : stopping a timeout



ghell
07-14-2003, 07:37 PM
ok, when i hold over something it stops moving, and when i move off it starts, but the move is with a setTimeout, so if you move your mouse over it really fast, it starts moving, then it doesnt stop, it keeps moving as it ws before, but now its moving double speed as the effects seem to stack, does anyone know how to stop it when this happens, a check to see if there is already a timeout running would be helpful.. ill work on it myself too but any help is much apreciated

Danne
07-14-2003, 08:18 PM
Try window.clearTimeout(timeoutID)
Ex;






// Function that requires cancelling the timeout
function openMenu() {
killCounter();
// Code to open
counterID = setTimeout('closeMenu();', 5000);
}


function killCounter() {
if(counterID) {
clearTimeout(counterID);
counterID = 0;
}
}

cheesebagpipe
07-14-2003, 09:21 PM
Code?

ghell
07-14-2003, 09:54 PM
thanks mate, it worked like a charm.. that actually worked.. not just one of those rabit foot things that pikies sell.. newho thanks... and are you just spanmming when you say "Code?" because if (you are) document.write("people like you make me sick")

argh! 2 much js for 1 day :o

cheesebagpipe
07-14-2003, 10:07 PM
No...code? means 'if you post something, I'd be glad to look at it and see - in case the previous post didn't answer your question - if I (we) can be of help'. People like you make us all sick. Have a nice day. :rolleyes:

Mr J
07-15-2003, 12:27 AM
ghell


document.write("people like you make me sick")

As cheesebagpipe said if you'd shown your code it would let us know exactly where the problem was instead of us having to guess or write out example codes.

You problem might have been solved with the addition of one extra line of code approximately 21 characters long.

Just a thought

:D

ghell
07-16-2003, 10:48 AM
but danne already fixed it and when people just pose "code?" they seem to be spamming .. the "peiple like you make me sick" was just a joke, thats why i put it in javascript :P no1 here hasa sense of humour

and i put it in an if statement, so if u werent spamming you shouldnt be able to read the text, lol

the "clearTimeout(counterID);" fixed it, as you should have known because it answered my question perfectly because that is the way to stop a timeout and my question was how do you stop a timeout? so there was no need for me to tell my code to anyone when one line was enough to fix it especially as it is a VERY large code, separated into 3 js files and an ASP file (and thats not cos i did it all the hard way or anything like that either)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum