Click to See Complete Forum and Search --> : setTimeout and the 'this' reference (finding my object)


Doug_Dyer
12-13-2002, 04:09 PM
I have a javascript class that would like to have its own setInterval feature. To do this, I would like the method invoked by the window to understand which object instance it is. Ideally, I could pas the this down but it looks like IE only allows:

window.setInterval("code", 100);

and not

window.setInterval(MyClass.myFunc, 100, this);

Is there any technique for the setTimeout/Interval handlers to understand which object instance?

Thanks in advance
Doug

Doug_Dyer
12-14-2002, 07:20 AM
Thanks thats an idea, but I was trying to avoid non-reentrant solutions since there may be more than one instantiated object each running its own timer.

I thought about a global array and each instantiation tacked itself on the end and remembered its index.