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 4 of 4
  1. #1
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts

    clearTimeout() and clearInterval()

    I'm looking at some documentation for clearTimeout(). I'm seeing this example:

    clearTimeout( timeoutIDnumber );

    Apparently, I'm supposed to reference some type of ID for the setTimeout, but I'm not sure how to go about that.

    Any help?

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.

  • #2
    Regular Coder
    Join Date
    Dec 2002
    Location
    the windy city
    Posts
    140
    Thanks
    0
    Thanked 0 Times in 0 Posts
    var t = setTimeout ("your_function", timer);

    clearTimeout(t);

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Doesn't look like core timer documentation, but some api ('class' lib?). Return timers to a persistent property (could be global var) for later clearing:

    var animTimerID = null;

    function anim() {
    .......
    if (animTimerID == null)
    animTimerID = setInterval(.......);
    }

    function stop_anim() {
    if (animTimerID != null) {
    clearInterval(animTimerID);
    animTimerID = null;
    }
    }

  • #4
    Regular Coder Skyzyx's Avatar
    Join Date
    Aug 2002
    Location
    Silicon Valley, CA
    Posts
    980
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Aaahh! That makes sense. Kinda like with new windows.

    Code:
    var win=window.open(...);
    
    win.close();
    Thanks guys! Big help.

    Creator of SimplePie and Tarzan AWS, co-founder of WarpShare, co-built the Y! Messenger website, usability-focused, and an INFJ personality.


  •  

    Posting Permissions

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