javascript functions
hello there fellows
i got a question regarding functions in JavaScript. how can i stop executing a function
which calls itself using setTimeout() method. For example, consider following functions:
var time = 0;
function start()
{
//start the timer
time++;
setTimeout("start(" + time + ")",1000);
}
function resetTimer()
{
time = 0;
return time;
}
now if i call the start() function for the first time, there's no problem but when i call resetTimer() and then again start() function,
the timeout seems to be going crazy fast - it doesn't increment time variable every second but it gets a lot faster. Every time i call start() function, time variable gets increased much faster every 1 second. I think you know what i mean. what i want is to call start function even million times but still the time variable will increase every second.
thanx :D:D
the genuine genius
__________________
www.campusgrind.com - college portal
|