This one is var static loop = 1;not valid, var loop = 1;but you are starting an endless cycle, so you cannot stop it this way.
Use setInterval instead
var int = self.setInterval(function(){myLoop()},100);
function myLoop() {
}
function stopLoop() {
window.clearInterval(int);
}
source
share