JS check IF every X seconds

Discussion in 'JavaScript' started by tautvys92, Dec 13, 2009.

  1. #1
    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.
     
    tautvys92, Dec 13, 2009 IP
  2. dimitar christoff

    dimitar christoff Active Member

    Messages:
    882
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    90
    #2
    
    var foo = false;
    var $handle = setInterval(function() {
        if (foo === true) {
            clearTimeout($handle);
            window.location.href = window.location.href;
        }
    }, 1000);
    
    Code (javascript):
     
    dimitar christoff, Dec 13, 2009 IP