How about calling clearInterval
?
You'll need the handle to the interval, though.
var myVar = setInterval(myTimer, 1000);
function myTimer() {
var d = new Date();
var t = d.toLocaleTimeString();
document.getElementById("demo").innerHTML = t;
}
function myStopFunction() {
clearInterval(myVar);
}
But if you can't or don't want to edit a 3rd party script, there is one thing you could do:
- override the window.setInterval function.
like
var backup = window.setInterval;
var my_array = [];
window.setInterval = function(interval, function){
var handle = backup(interval, function);
my_array.push(handle);
return handle;
}
then you can get all the handles from my_array, and clear them all.
Naturally, this would have to be done before you load any other scripts.