Wes Gamble
2008-Jan-17 21:23 UTC
OT: Dynamically calculating the height of an HTML document
Apologies for the off-topicness, this is really a Javascript question, but I figure someone here may know how to do it. I need to dynamically add a "footer" to an already existing HTML page, sight unseen. Currently, I insert a <div> element just before the </body> end tag, and this works most of the time. But, sometimes the <div> is rendered to the right of a table _if_ the entire page is laid out in one big table. I have been unable to come up with a way to force my content into the lower left hand corner, even using absolute positioning CSS directives (in one case, the table extends beyond what the browser thinks the "bottom" of the page is). I''m looking for a way to inspect the DOM to figure out the height of all of the existing content on the page, then I figure I can absolute position with a left margin of 0 and a top margin of <whatever the height of existing content is>. I tried getting document.body.offsetHeight, but this returns 0 in both FF and IE. Anyone have any ideas how to do this, without resorting to manipulating any of the existing HTML? Thanks, Wes -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Keynan Pratt
2008-Jan-18 08:48 UTC
Re: OT: Dynamically calculating the height of an HTML docume
without manipulating the html. Well you could throw it out completely which is never a wrong move when facing a tabular layout but i digress. Your best bet is to insert at the end of the body element the footer content and just above the footer a clear (ie: <div class="clear"> </div> <div id="footer"> blah blah </div> with css: #footer{ float:left; } .clear{ clear:both; height:0; font-size:0; } -K -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Wes Gamble
2008-Jan-18 16:09 UTC
Re: OT: Dynamically calculating the height of an HTML docume
Keynan Pratt wrote:> without manipulating the html. Well you could throw it out completely > which is never a wrong move when facing a tabular layout but i digress.Unfortunately, this is submitted HTML and I don''t have control over it before I need to add my footer. Wes -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Wes Gamble
2008-Jan-18 16:48 UTC
Re: OT: Dynamically calculating the height of an HTML docume
Keynan Pratt wrote:> without manipulating the html. Well you could throw it out completely > which is never a wrong move when facing a tabular layout but i digress. > > Your best bet is to insert at the end of the body element the footer > content and just above the footer a clear (ie: > > <div class="clear"> </div> > <div id="footer"> > blah blah > </div> > > with css: > > #footer{ > float:left; > } > > .clear{ > clear:both; > height:0; > font-size:0; > } > > -KKeynan, Thanks this works well. So I guess a one-table layout comes with an implied float: left. Wes -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Greg Donald
2008-Jan-18 22:34 UTC
Re: OT: Dynamically calculating the height of an HTML document
On 1/17/08, Wes Gamble <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I''m looking for a way to inspect the DOM to figure out the height of all > of the existing content on the page, then I figure I can absolute > position with a left margin of 0 and a top margin of <whatever the > height of existing content is>. > > I tried getting document.body.offsetHeight, but this returns 0 in both > FF and IE. > > Anyone have any ideas how to do this, without resorting to manipulating > any of the existing HTML?You might try examining the HTML with Firebug to see if there''s something else in the DOM that has a height attribute you can use. Don''t feel bad if you find nothing, even Gmail uses <br /> tags for additional spacing in certain "empty" places. -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---