title: How to show an alert in javascript when the countdown time is over?
body: <p>This is my code for displaying countdown time for 1 minute on a HTML page:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Countdown&lt;/title&gt;
  &lt;script type="text/javascript"&gt;
  // set minutes
  var mins = 1;
  // calculate the seconds (don't change this! unless time progresses at a different speed for you...)
  var secs = mins * 60;
  function countdown() {
  setTimeout('Decrement()',1000);
  }
  function Decrement() {
  if (document.getElementById) {
      minutes = document.getElementById("minutes");
      seconds = document.getElementById("seconds");
      // if less than a minute remaining
      if (seconds &lt; 59) {
          seconds.value = secs;
      } else {
          minutes.value = getminutes();
          seconds.value = getseconds();
      }
      secs--;
      setTimeout('Decrement()',1000);
  }
  }
  function getminutes() {
  // minutes is seconds divided by 60, rounded down
  mins = Math.floor(secs / 60);
  return mins;
  }
  function getseconds() {
  // take mins remaining (as seconds) away from total seconds remaining
  return secs-Math.round(mins *60);
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;input id="minutes" type="text" style="width: 26px; border: none; background-color:none; font-size: 16px; font-weight:bold;"&gt;m 
  &lt;input id="seconds" type="text" style="width: 26px; border: none; background-color:none; font-size: 16px; font-weight: bold;"&gt;s
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>
  
  <p>I want to show an alert message displaying "Time over" when the countdown reached to <code>0m 0s</code> and when the user click on <code>ok</code> button of the alert box, the page should be redirected to <code>example.html</code>. How can I achieve this? </p>
  
  <p>Edit : I have done this way-</p>
  
  <pre><code>function Decrement() {
  if (document.getElementById) {
      minutes = document.getElementById("minutes");
      seconds = document.getElementById("seconds");
      // if less than a minute remaining
      if (seconds &lt; 59) {
          seconds.value = secs;
      } else {
          minutes.value = getminutes();
          seconds.value = getseconds();
      }
  
      if (minutes==0 &amp;&amp; seconds==0){
          if (window.confirm('Time over'))
          {
              window.location="http://www.example.com";
          }
          else
          {
              window.location="http://www.example.com";
          }
      }
      secs--;
      setTimeout('Decrement()',1000);
  }
  </code></pre>
  
  <p>But it is not working. The counter goes negative instead of asking for conformation at 0m 0s. How to make it working?</p>