title: Get X/Y Coordinates on Button using 'onclick' and JavaScript
body: <p>I am a JavaScript beginner and am looking for a way to get the x and y coordinates on a button when it's clicked.  This works in Opera, IE9 and Chrome but I can't get it to work in Firefox.  Here is my code so far:</p>
  
  <p>Function in JavaScript:</p>
  
  <pre><code>function buttonClick(subEvent)
  {
      var mainEvent = subEvent ? subEvent : window.event;
  
      alert("This button click occurred at: X(" +
      mainEvent.screenX + ") and Y(" + mainEvent.screenY + ")");
  }
  </code></pre>
  
  <p>Here is the HTML section:</p>
  
  <pre><code>&lt;input type="button" onclick="buttonClick()" value="Submit"/&gt;
  </code></pre>
  
  <p>The idea here is to only get the coordinates when the button is clicked and to get the actual coordinates within the border of the button itself.  Getting coordinates on the screen is easier and finding that solution for all browsers was already accomplished.</p>
  
  <p>Thanks in advance for any assistance.</p>