title: continue execution while alert box is on
body: <p>I have a Javascript block in which it creates a timer based on mouse movements. If you are not doing any activity the timer starts and when it reaches say 1 minute left time it displays an alert to the user and if the user does not respond it navigates to another page. The problem I am facing is that when I show an alert to the user the timer execution stops and it just waits for the user to press enter. What I need is that the timer should continue in the background whether the user clicks OK or not.</p>
  
  
  
  <pre><code>var mins, secs, TimerRunning, TimerID;
  TimerRunning = false;
  
  var activity;
  document.documentElement.onmousemove = function () {
      clearInterval(activity);
       activity = Init();
     // activity = setInterval(saySomething, 5000);
  }
  
  function Init() //call the Init function when u need to start the timer
  {
      mins = 2;
      secs = 0;
      StopTimer();
      StartTimer();
  }
  
  function StopTimer() {
      if (TimerRunning)
          clearTimeout(TimerID);
      TimerRunning = false;
  }
  
  function StartTimer() {
      TimerRunning = true;
      window.status = "if no activity is detected you will be logged out in " + Pad(mins) + ":" + Pad(secs);
      TimerID = self.setTimeout("StartTimer()", 1000);
  
      Check();
  
      if (mins == 0 &amp;&amp; secs == 0)
          StopTimer();
  
      if (secs == 0) {
          mins--;
          secs = 60;
      }
      secs--;
  
  
  }
  
  function Check() {
      if (mins == 1 &amp;&amp; secs == 0)
          toggle();
       alert("You have only 2 minutes remaining");
      if (mins == 0 &amp;&amp; secs == 0) {
  
          window.location = "http://Test";
  
      }
  }
  
  function Pad(number) //pads the mins/secs with a 0 if its less than 10
  {
      if (number &lt; 10)
          number = number;
      return number;
  }
  </code></pre>