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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Determine Position after Dynamic Move 1

Status
Not open for further replies.

ToddWW

Programmer
Mar 25, 2001
1,073
US
How can I determine the position of a DIV element AFTER it has been moved dynamically.

Say I expand a DIV element through script. This process pushes other DIV elements around the page. Is there any way to determine their NEW position. I have tried everything including changing the position properties. Even if I set the property to RELATIVE, and set initial left/right values to the style, after the DIV has moved dynamically, those numbers don't change.

Any help would be appreciated.

ToddWW
 
Todd:

For finding the current position of any element, QuirksMode has an excellent discussion of the topic using the [tt]offsetTop[/tt] and [tt]offsetLeft[/tt] properties here.

This question probably belongs in the JavaScript forum because you need JavaScript to interact with elements after the page has been rendered.

--
-- Ghodmode

Give a man a fish and he'll come back to buy more... Teach a man to fish and you're out of business.
 
The question is, why do you need the new position of the div. If you use normal document flow, your divs will move nicely where they need to go to make room as you expand them and move them...
 
Vraga.. The issue is not normal document flow but I appreciate your input.

I am trying to get the cursor position, relative to the main document window, when clicking inside an iframe.

Ghodmode was correct. offsetTop and offsetLeft allowed me to calculate the position of the iframe element in conjunction with the click event.x event.y coordinates inside the iframe to determine the cursor position relative to the main document window.

It's for an interface to drag and drop elements between iframes.

Thanks Ghodmode. It works perfectly. !!

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top