var i = 3400;
function progress() {
i = 34000;
window.setInterval(function () {
i = i - 100;
document.getElementById("progress").firstChild.data = i;
}, 100);
}
This code is getting faster and faster. The function progress is called every 3 seconds, but I can’t change the it’s called because it’s event based. After around 10 calls i is getting negative!
Since progress is called every 3 seconds, you need to avoid that it creates new intervals repeatedly. Using
clearTimeoutresets the timer anytime you call progress. However, without knowing what exactly you want to achive it’s difficult to provide an accurate answer.