1

Possible Duplicate:
JavaScript - Is it possible to view all currently scheduled timeouts?

Is there any way to access the list of all functions that are scheduled to be called (or strings scheduled to be evaluated) by window.setTimeout() or window.setInterval()?

Something that returns an Array of objects identical to those returned when these functions were originally called.

Community
  • 1
  • 1
Kaustubh Karkare
  • 1,083
  • 9
  • 25

3 Answers3

1

No. The WindowTimers interface doesn't provide any method to get the list of currently queued tasks:

[Supplemental, NoInterfaceObject]
interface WindowTimers {
  long setTimeout(in any handler, in optional any timeout, in any... args);
  void clearTimeout(in long handle);
  long setInterval(in any handler, in optional any timeout, in any... args);
  void clearInterval(in long handle);
};
Window implements WindowTimers;

You have to write your own code in order to keep track of the handlers.

Zeta
  • 103,620
  • 13
  • 194
  • 236
0

I don't think you can except you write a wrapper for setTimeout and setInterval and implement calling them inside and pushing the functions to an Array

0

I can't answer your question (although I don't think there is a way), but depending on what you're trying to do, you could write a wrapping function and then either add it to an array that you control or fire an event you can put a listener on, or ...

Of course, this would only give you control over what functions you set a timer on yourself.

var stack = new Array();

window.mySetTimeout = function (func, delay) {
   stack.push(func);
   window.setTimeout(func, delay); 
}

function doSomething () {
   return true;
}

window.mySetTimeout(doSomething, 500);
console.log(stack);

Edit: I guess I was a little slow there.

Ingo Bürk
  • 19,263
  • 6
  • 66
  • 100