Get exact cursor coordinates in textarea for FireFox
<p>I try to get the exact co-ordinates of cursor (x,y) in textarea for Gecko (firefox). 
I get co-ordinates of cursor (x,y) in IE but in Gecko can't get anything.</p>

<pre><code>if (document.selection) {   // for IE it working.     
        var r = document.selection.createRange();               
        if(input.nodeName == 'TEXTAREA') {
          var x = r.offsetLeft - r.boundingLeft;
          var y = r.offsetTop - r.boundingTop;
        } else {
          var x = r.offsetLeft;
          var y = r.offsetTop;
        }       
        return {
          x : x,
          y : y
        };
</code></pre>
