title: Javascript - Track mouse position
body: <p>I am hoping to track the position of the mouse cursor, periodically every t mseconds. So essentially, when a page loads - this tracker should start and for (say) every 100 ms, I should get the new value of posX and posY and print it out in the form. </p>
  
  <p>I tried the following code - but the values do not get refreshed - only the initial values of posX and posY show up in the form boxes. Any ideas on how I can get this up and running ? </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt; Track Mouse &lt;/title&gt;
  &lt;script type="text/javascript"&gt;
  function mouse_position()
  {
      var e = window.event;
  
      var posX = e.clientX;
      var posY = e.clientY;
  
      document.Form1.posx.value = posX;
      document.Form1.posy.value = posY;
  
      var t = setTimeout(mouse_position,100);
  
  }
  &lt;/script&gt;
  
  &lt;/head&gt;
  
  &lt;body onload="mouse_position()"&gt;
  &lt;form name="Form1"&gt;
  POSX: &lt;input type="text" name="posx"&gt;&lt;br&gt;
  POSY: &lt;input type="text" name="posy"&gt;&lt;br&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>