PDA

View Full Version : calling setTimeout from within a method


bryndyment
05-08-2003, 07:40 AM
Heya,

I have a method that wants to call 'setTimeout', but I don't know how to specify another method as the callback function.

So, I want something like this:

function methodOne() {
setTimeout( 'this.methodTwo()', 5000 );
}

function methodTwo() {
alert( 'success!' );
}

I get an error "Can't execute code from a freed script", which I think is really unfair.

Any ideas, smart people?

beetle
05-08-2003, 08:35 AM
You'd have to call the object globally (with it's instantiated name), or use something like Algorithm's timer class, which I mirror here (http://www.peterbailey.net/dev/jsclasses/) and have used successfully for many applications such as what you are describing