Hello everyone, I''m trying to get the height of the page where my script is running. I''m not trying to get the dimensions of the viewport, but the page. If the page is 1000px tall, and the viewport is 600px tall (thus, a scrollbar shows), i want to get "1000" independently of the position of the scroll. My best finding so far has been $(document.body).getDimensions() However, on IE6 it''s giving me the height of the viewport. Searching for this in this forum I found some comment about quirks mode... If this is the problem, I need some kind of alternate solution. I''m writing a bookmarklet that''s supposed to work on pretty much any page, so I need it to work both in quirks and standards mode. Btw, I don''t NEED to use the prototype methods. Anything that''ll work cross-browser is good for me. Thanks in Advace Daniel --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Ensure that you are not in quirks mode! This means put a doctype declaration into your document. That one was pointed out to me previously. On Jun 3, 11:20 am, Daniel Magliola <dmagli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello everyone, > > I''m trying to get the height of the page where my script is running. > I''m not trying to get the dimensions of the viewport, but the page. If > the page is 1000px tall, and the viewport is 600px tall (thus, a > scrollbar shows), i want to get "1000" independently of the position > of the scroll. > > My best finding so far has been $(document.body).getDimensions() > > However, on IE6 it''s giving me the height of the viewport. > > Searching for this in this forum I found some comment about quirks > mode... > If this is the problem, I need some kind of alternate solution. I''m > writing a bookmarklet that''s supposed to work on pretty much any page, > so I need it to work both in quirks and standards mode. > > Btw, I don''t NEED to use the prototype methods. Anything that''ll work > cross-browser is good for me. > > Thanks in Advace > Daniel--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Polgardy
2008-Jun-03 16:06 UTC
Re: Getting the height of a page (document / body)
Well, I think he''s saying that he''s writing a bookmarklet that could in theory be executed on whatever crappy page the user happens to be viewing. Would have to do some hunting to see how to reliably get this info in quirks mode. On Tue, Jun 3, 2008 at 10:56 AM, blechler <lechler-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Ensure that you are not in quirks mode! This means put a doctype > declaration into your document. That one was pointed out to me > previously. > > On Jun 3, 11:20 am, Daniel Magliola <dmagli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hello everyone, > > > > I''m trying to get the height of the page where my script is running. > > I''m not trying to get the dimensions of the viewport, but the page. If > > the page is 1000px tall, and the viewport is 600px tall (thus, a > > scrollbar shows), i want to get "1000" independently of the position > > of the scroll. >-- Science answers questions; philosophy questions answers. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
document.body is not the top level element. document.documentElement is: $(document.documentElement).getDimensions(); The fun part starts with quirks mode, when document.body acts as document.documentElement. You could check for such case easily: var isBodyRoot = (function(){ var docEl = document.documentElement; return !!(docEl && docEl.clientWidth == 0); })(); It also makes sense to get Math.max of viewport and documentElement/ body values. - kangax On Jun 3, 11:20 am, Daniel Magliola <dmagli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello everyone, > > I''m trying to get the height of the page where my script is running. > I''m not trying to get the dimensions of the viewport, but the page. If > the page is 1000px tall, and the viewport is 600px tall (thus, a > scrollbar shows), i want to get "1000" independently of the position > of the scroll. > > My best finding so far has been $(document.body).getDimensions() > > However, on IE6 it''s giving me the height of the viewport. > > Searching for this in this forum I found some comment about quirks > mode... > If this is the problem, I need some kind of alternate solution. I''m > writing a bookmarklet that''s supposed to work on pretty much any page, > so I need it to work both in quirks and standards mode. > > Btw, I don''t NEED to use the prototype methods. Anything that''ll work > cross-browser is good for me. > > Thanks in Advace > Daniel--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---