I think you'd need to wrap setInterval
in your own mySetInterval
that keeps track of the clearable id:
function mySetInterval(f,t) {
var x =
setInterval(
function() {
f();
clearInterval(x);
},
t
)
}
mySetInterval(function() { alert("foo"); }, 1000);