The timeout mechanism can be used to defer the execution of a block of script code. You can defer several blocks at once if necessary, so there could be a number of pending timeout triggers. You must be able to identify the one that you want to clear.
When you create a timeout trigger with the setTimeout() method, it will return back to you with a value that corresponds uniquely to that trigger's set-up context. You can use that value later to clear the timeout trigger.
You must be careful not to clear timeout triggers more than once.
Be careful when clearing interval timers. If you try to clear one that does not exist, it can sometimes crash the browser.
It is highly likely that the interval may have elapsed and the timeout no longer exists to be cleared. A more reliable technique that is less prone to browser crashes is to set a flag value in a global variable and then test that from within the timeout invoked function.
Prev | Home | Next |
Window.clearInterval() | Up | Window.clientInformation |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |