var ps;function pause()
{
   ps=setInterval("outtime++",1000);
}function continue()
{
  clearInterval(ps);
}

解决方案 »

  1.   

    <script language="javascript">
      var outtime=30;
      function leavePage()
      {
          if(0==outtime)
          {
              location.href="";
          }
          else
          {
              outtime -= 1;
              document.all.countdown.innerText = outtime + " ";
          }
      }
      
      function go()
      {
          t = setInterval("leavePage()", 1000);
      }  function stop_exec()
      {
      clearInterval(t);
      }go();
    </script>
    <span id=countdown></span>
    <br>
    <input type=button onclick="stop_exec();" value="stop timer">
    <input type=button onclick="go();" value="start timer">