title: JavaScript Timer Pause
body: <p>The code is below. How would you set a button to pause the timer and resume when pressing resume? The // marks below are where I'm placing my pause and resume tags. Thank you for all of your help!!</p>
  
  <pre><code>&lt;head&gt;
  &lt;script type="text/javascript"&gt;
  
  var d1 = new Date();
  d1.setHours(1,0,0);
  
  function f(){
  var h= d1.getHours();
  var m= d1.getMinutes();
  var s=d1.getSeconds();
  m= (m&lt;10)?"0"+m: m;
  s= (s&lt;10)? "0"+s : s;
  
  var el= document.getElementById("inputid");
  el.value= h+":"+m+":"+s;
  d1.setSeconds(d1.getSeconds()-1);
  if( h==0 &amp;&amp; m==0 &amp;&amp; s==0 ) clearTimeout(t)
  var t= setTimeout("f()",1000);
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form&gt;&lt;input type="text" id="inputid"&gt;&lt;/form&gt;
  &lt;script type="text/javascript"&gt;f()&lt;/script&gt;
  
  //pause and resume buttons would go here.
  &lt;/body&gt;
  </code></pre>