title: How enable and disable setTimeout onclick
body: <p>I have a function that executes on page load.  The function executes every 30 seconds using setTimeout. I want to be able to enable and disable setTimeout onclick I have the following code below...</p>
  
  <pre><code>  &lt;input id="vw" value="" type="hidden"&gt;
    &lt;a href="#" onclick="document.getElementById('vw').value='0';&gt;click here&lt;/a&gt;
  
      &lt;script&gt;
      /* JAVASCRIPT BELOW */
      function mPb(){
  
      var vw = escape(document.getElementById('vw').value);
  
      if(vw == ''){//DO NOT SWITCH VIEW IF EMPTY
  
      var sTo = setTimeout("mPb()", 30000);
  
      } else {
  
      clearTimeout(sTo);  
  
      }
  
  }//END VIEW MY FEED 
  
     //ON SERVICE LOAD DISPLAY SHITE INSTEAD OF ONLOAD  
     window.addEventListener ? 
     window.addEventListener("load",mPb,false) : 
     window.attachEvent &amp;&amp; window.attachEvent("onload",mPb);
     &lt;/script&gt;
  </code></pre>