Jump to content

image positions


MrAdam

Recommended Posts

does anybody know how to return the positions of an image (ie. top, left), that hasn't been set to position:absolute ? - if it's even possible..for example:

<script type="text/javascript">function retrnPos(obj) {	alert(' .. image top and image left .. ');}</script><img src="..." onClick="retrnPos(this);" />

-Thanks

Link to comment
Share on other sites

jesh: can that be applied to other elements too? like div?
Yeah, I use it all the time. It's part of the DOM. You can get the left and top positions (offsetLeft, offsetTop) as well as the height and width (offsetHeight, offsetWidth) for any element.Different browsers seem to return different numbers (no suprise there, right?), but they are internally consistent: obj1.offsetLeft - obj2.offsetLeft should return the same value in both Firefox and IE.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...