Niccaman Posted April 18, 2009 Share Posted April 18, 2009 ...to kill a function that is looping via timeout from another function? Quote Link to comment Share on other sites More sharing options...
Kieran Menor Posted April 19, 2009 Share Posted April 19, 2009 I suppose you could do something like it... Instead of looping you could use setInterval( expression , timeout ) to call your function every timeout milliseconds. setInterval returns an ID of sorts that can be used to cancel it. Consider this: function loop() { // code to repeat } var interval = setInterval("loop()", 1); // run loop() every millisecond setTimeout("clearInterval(interval)", 5000); // cancel in 5 seconds Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.