How to execute IF in JS every X seconds? For example, I need to check IF variable1 is more than variable2 and if it is, refresh page.
var foo = false; var $handle = setInterval(function() { if (foo === true) { clearTimeout($handle); window.location.href = window.location.href; } }, 1000); Code (javascript):