Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to keep the Id of each interval, timeout and requestAnimationFrame you've created and call <code>window.clearInterval(id)</code> etc. on them.</p> <p>A verfy hackish/brute force way to do it would be something like:</p> <pre><code>for (var i = 1; i &lt; 99999; i++) { window.clearInterval(i); window.clearTimeout(i); window.mozCancelAnimationFrame(i); // Firefox } </code></pre> <p>But I wouldn't recommend that.</p> <p><strong>Update:</strong></p> <p>To do it after a certain amount of time:</p> <pre><code>setTimeout(function () { for (var i = 1; i &lt; 99999; i++) { window.clearInterval(i); window.clearTimeout(i); window.mozCancelAnimationFrame(i); // Firefox } }, 3000); // After 3 seconds </code></pre> <p><strong>Update 2:</strong></p> <p>I don't believe there is a better way than the brute force way if you don't keep a reference for each time out etc, so to make it a bit easier to do that (as suggested by <a href="https://stackoverflow.com/a/958498/678801">this SO answer</a>), you could override the default setInterval:</p> <pre><code>var intervals = new Array(); window.oldSetInterval = window.setInterval; window.setInterval = function(func, interval) { intervals.push(oldSetInterval(func, interval)); } // Now you can loop over intervals and clear them // one by one when ever you want to. for (var interval in intervals) { window.clearInterval(interval); } </code></pre> <p>The example shows how to do it for <code>setInterval</code>, but could of course be done the same way on <code>setTimeout</code> and <code>requestAnimationFrame</code> as well.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload