title: event.offsetX in Firefox
body: <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;script language="javascript"&gt;
  function main(){
      var canvas = document.getElementById("canvas");
      canvas.addEventListener("mousemove", function(e){
          if (!e) e = window.event;
          var ctx = canvas.getContext("2d");
  
          var x = e.offsetX;
          var y = e.offsetY;
  
          ctx.fillRect(x, y, 1, 1);
      });
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload="main();"&gt;
  &lt;div style="width: 800px; height: 600px; -webkit-transform: scale(0.75,0.75); -moz-transform: scale(0.75,0.75)"&gt;
      &lt;canvas id="canvas" width="400px" height="400px" style="background-color: #cccccc;"&gt;&lt;/canvas&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Please consider the above quick and dirty example.
  Please notice that my canvas is contained by a div having a scale transform applied.
  The above code works perfectly on any webkit based browser. While moving the mouse it draws points on the canvas.
  Unfortunately it doesn't in Firefox as its event model does not support the offsetX / Y properties.
  How can I transform mouse coordinates from (perhaps) event.clientX (which is supported in firefox too) into canvas relative coordinates taking into account canvas position, transform etc?
  Thanks, Luca.</p>