while(true){
window.setTimeout(function() {
myMethod()
}, 15000);
}
function myMethod() {
alert(\"repeat\
The trick here, I think, would be to have the check inside the setTimeout and use clearTimeout when the condition is met. Here's an example that logs a count to the console every 1.5 seconds until 0.
function looper(time) {
if (time > 0) {
console.log(time);
var timer = setTimeout(looper, 1500, --time);
} else {
clearTimeout(timer);
}
}
looper(10);
You would obviously change the condition to that required by your program.
DEMO