alternative to finding an <img> x and y origin
<p>I have the following js which is basically to find the x and y origin of the top left of the  tag. This however, doesn't always work, for some reason, and some times it work. Not sure why, but some of the offsetLeft and offsetTop are 0. Do you have any other alternative to this?</p>

<pre><code>function f() {
  var el = document.elementFromPoint(%f, %f);
  var pos = [el.offsetLeft, el.offsetTop];
  var parent = el.offsetParent;
  if (parent != el) {
    while (parent) {
      pos[0] += parent.offsetLeft;
      pos[1] += parent.offsetTop;
      parent = parent.offsetParent;
    }
  }
  return pos.toString();
} f();
</code></pre>

<p>I am also trying to get the width and height of the image by doing element.clientWidth and element.clientHeight. Why is this giving me 0 as well?</p>
