Niccaman Posted April 18, 2009 Share Posted April 18, 2009 ...to kill a function that is looping via timeout from another function? Link to comment https://forums.phpfreaks.com/topic/154639-is-it-possible/ 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 Link to comment https://forums.phpfreaks.com/topic/154639-is-it-possible/#findComment-814018 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.