ta*****@gmail.com wrote:
question I have never been able to solve since the 90s...
I want to find x, y location of a layer or an image, or any other item
on a webpage.
1. It could be relatively or absolutely positioned.
2. It does not matter what browser the user is using.
what's the correct javascript code?
example: find x, y location of the image "someImage"
<html>
<body>
........ some html here....
<img src="someImage.gif" id="someImage" />
........ some html here....
<body>
</html>
I use a program called ScreenCalipers that might be of use to you. You
can download a limited feature version for free at
http://www.iconico.com/caliper/v3upgrade.aspx . Paying for it will add
more features. You can measure the x and y distances between any two
points in px, cm, inches, or other units. A measurement from the left
of the screen to the start of an image will give the x coordinate for
the image, and measurement from the top of the screen to the top of the
image will give the y coordinate. You can also measure the width and
height of the image. I do not know exactly what code is used in the
ScreenCalipers program, but it seems to work well for me.