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

Reading DIV element props problem

Status
Not open for further replies.

mirirom

Programmer
Jul 21, 2001
110
US
hi,

i'm wondering how to go about returning a calculated "top" value for a dynamically placed DIV element, when the element has been been positioned relatively on the page.

for example, i have a set of DIVs that are being built on the fly and flow down the course of a page. the default "top" value of these DIVs is "auto" and it's not practical (or feasibly possible) to assign "top" values beforehand.

i can't imagine this value is untouchable. any advice is greatly appreciated; thanks in advance!



 
try:

<div id=&quot;test&quot;></div>

//Get the div tag object

var objDiv=document.getElementById(&quot;test&quot;);
alert(objDiv.style.posTop);

See if that works for you.

MrGreed

&quot;did you just say Minkey?, yes that's what I said.&quot;
 
hi thanks,

unfortunately, posTop always returns zero unless the style.top property has been explicitely assinged (at least that's what the W3D states). however, your thought led me down quite a few new search paths and found a different work-around.

there are one or two static elements that will always have the same size. with this in mind, setting size attributes for this is ok, which allow values to be calculated on neighboring elements and neighboring elements and... it seems to be the long/hard solution but at least it works, on paper.

but now that i've gotten my DIVs moving about, they're disappearing after changes are made to their attributes. is there some kind of call to a page paint() function for that must be made or...?

tx again for your reply.


..:: mirirom ::..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top