I would advise to use jQuery and its method
.offset()
which returns the current position of any element relative to
document:
imgElement = $("#myImage");
elementPosition = imgElement.offset();
top = elementPosition.top;
left = elementPosition.left;
Please see
http://api.jquery.com/offset/[
^].
In this example, the
img
element is selected by its
id
attribute value "
myImage
":
<img alt="some image" src="someURL.png" id="myImage" />
For other selectors, please see
http://api.jquery.com/category/selectors/[
^].
See also position relative to a parent element, good to know:
http://api.jquery.com/position/[
^].
To learn about jQuery, please see:
http://en.wikipedia.org/wiki/JQuery[
^],
http://jquery.com/[
^],
http://docs.jquery.com/Main_Page[
^].
—SA