Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Element Coordinates 1

Status
Not open for further replies.

tweenerz

Programmer
Mar 25, 2002
202
US
I am positioning an element via percentages (i.e. 50% - middle of the page) through the style element of the div tag(style="position:relative;left:50%"). That way it will stay in the middle of the page at all times. Since I did it this way, is it possible to grab the actual pixel coordinates of the element at any given time through javascript?

Reason being, I want to test other elements that are scrolling by to see if they are over this element; so I need to compare x coordinates. But since I used percentages in the style attribute, the left style is not populated.

Any help is greatly appreciated.
 
you can find this information in the offset attributes.

eg

document.all.mydiv_id.offsetLeft

or offsetWidth
offsetHeight
offsetTop

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top