griffinmt Posted September 15, 2006 Share Posted September 15, 2006 This could be entered into this forum or CSS forum I suppose.I want to be able to dynamically place a 'block' of html output (such as a small table or image) adjacent to and below another block. In fact there are several 'moveable' blocks and there are several 'target' blocks. When a moveable block is selected, I wish to set its position to absolute, set its left and top pixal value, set its zindex, then set it as display:block;I am not having trouble with the code to do this, but I AM having trouble determining the absolute position values of the target block bottom right corner. As defined, these targets temselves are 'floating' as relative blocks in their own parents space.If this is not clear, I will try to explain in another way perhaps.Anyone know how to get the absolute position (and dimensions) of any named block?? Link to comment Share on other sites More sharing options...
scott100 Posted September 16, 2006 Share Posted September 16, 2006 I am not having trouble with the code to do this, but I AM having trouble determining the absolute position values of the target block bottom right corner. As defined, these targets temselves are 'floating' as relative blocks in their own parents space.If this is not clear, I will try to explain in another way perhaps.Anyone know how to get the absolute position (and dimensions) of any named block??To get positions you would use:var getTop=document.getElementById("blah").style.top;use the same for left, width and height.To get the bottom right corner you would need to add the top + height then left + width. You might run into some trouble though as im sure .style.blah returns values with px appended so there actually strings not numbers, you would need to chop px off the end (split()) then convert what's left into a true number (parseInt()).Good luck Link to comment Share on other sites More sharing options...
griffinmt Posted September 16, 2006 Author Share Posted September 16, 2006 To get positions you would use:use the same for left, width and height.To get the bottom right corner you would need to add the top + height then left + width. You might run into some trouble though as im sure .style.blah returns values with px appended so there actually strings not numbers, you would need to chop px off the end (split()) then convert what's left into a true number (parseInt()).Good luck The problem with that approach is two-fold:if the target block wasn't defined with a style that contains a top or left value, you can't retrieve the default placement values. if you did get any values returned (minus the px), they would be relative to IT'S parent, not absolute for the window. The moveable block is completely distinct from any of that lineage. Link to comment Share on other sites More sharing options...
Chocolate570 Posted September 16, 2006 Share Posted September 16, 2006 Check this page out.http://msconline.maconstate.edu/tutorials/...sdhtml15-03.htmI think that's what you want? Link to comment Share on other sites More sharing options...
griffinmt Posted September 16, 2006 Author Share Posted September 16, 2006 Check this page out.http://msconline.maconstate.edu/tutorials/...sdhtml15-03.htmI think that's what you want?On first observation, I think I can use this link to help solve my problem. But won't be able to work on this till Sunday Afternoon.Thanks for the help, I'll let you know if I get it working. Link to comment Share on other sites More sharing options...
griffinmt Posted September 17, 2006 Author Share Posted September 17, 2006 After doing some more digging and reading (and testing), the previously mentioned link did not do the job for me as needed.But what does work are the object properties:.offsetHeight.offsetWidth.offsetlLeft.offsetTop.offsetParentusing these to accumulate current relative positions in reference to each subsequent parent object lets you iterate up the chain to determine the actual absolute values of any object. Then a moveable object can be placed using that info in the calculation.Not sure if any of this works in other browsers, but since my audience is (should be) IE6+, that is fine with me.Thanks, Link to comment Share on other sites More sharing options...
Webworldx Posted September 18, 2006 Share Posted September 18, 2006 Hi Martyn,Just following up on that - QuirksMode has always provided me with the best object position finder: http://www.quirksmode.org/js/findpos.html, along with what works in each browsers. Very informative Link to comment Share on other sites More sharing options...
reportingsjr Posted September 18, 2006 Share Posted September 18, 2006 Scott, I actual triec this before with something. I beleive I was making something move left or right, and up or down.I think.. (just think, not positive) that you can use int(var_name) and it will only return the number.. You might want to check up on this though. Link to comment Share on other sites More sharing options...
aspnetguy Posted September 18, 2006 Share Posted September 18, 2006 I think the function you are refering to is parseInt() Link to comment Share on other sites More sharing options...
Chocolate570 Posted September 18, 2006 Share Posted September 18, 2006 Aspnetguy's right: It's parseInt(string,base). The base allows you to convert the string into a number, and then format it according to the base---for example,parseInt('077',10) is 77, because 077 in base 10 is 77. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now