Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts

    stopping a timeout

    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

  • #2
    Regular Coder
    Join Date
    Aug 2002
    Location
    São Paulo, Brazil
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try window.clearTimeout(timeoutID)
    Ex;
    Code:
    
    
    
    // Function that requires cancelling the timeout
    function openMenu() {
        killCounter();
        // Code to open
        counterID = setTimeout('closeMenu();', 5000);
    }
    
    
    function killCounter() {
        if(counterID) {
            clearTimeout(counterID);
            counterID  = 0;
        }
    }
    /Daniel

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code?

  • #4
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    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

  • #5
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    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


  • #7
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    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)
    Last edited by ghell; 07-16-2003 at 09:54 AM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •