title: How do I stop a window.setInterval in javascript?
body: <p>I have a javascript function that is called every 2000ms.  I want to stop this so I can have the user do other things on the page without it being called again.  Is this possible?  Here is the function that gets called every 2000ms:</p>
  
  <pre><code>window.setInterval(function getScreen (sid) {
          if (window.XMLHttpRequest)
          {// code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
          }
          else
          {// code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
          }
          xmlhttp.onreadystatechange=function()
          {
          if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200)
            {
              document.getElementById("refresh").innerHTML=xmlhttp.responseText;
            }
          }
          xmlhttp.open("POST","getScreen.php?sid="+&lt;?php echo $sid; ?&gt;,true);
          xmlhttp.send();
      },2000);
  </code></pre>