title: capture event when the mouse pointer outside of the browser viewport
body: <p>i am writing a simple infinite counter in javascript when the page loads it starts counting </p>
  
  <p>i would like to stop the counter when the mouse pointer is outside of the viewport </p>
  
  <p>please help?</p>
  
  <p></p>
  
  <pre><code>        var i=0;
  
  
              setInterval(function (){
                 i++;
  
                 document.getElementById("counterLoop").innerHTML=i;
  
              },1000);
  
      var viewportWidth  = document.documentElement.clientWidth;
       var viewportHeight = document.documentElement.clientHeight;
  
  
       function getCursorXY(e) {   
  CurX = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
  CurY = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  
  }
  </code></pre>
  
  <p>how can i capture mouse move event ouside of the viewport width and heigth</p>