Given this code: ----------------------------------------------------- <html> <head> <title></title> <script type="text/javascript" src = "/js/prototype.js"></script> <script type="text/javascript"> function init() { alert(document.viewport.getHeight()); } Event.observe(window, ''load'', init); </script> </head> <body> </body> </html> -------------------------------------------------------- In FF the alert says 8, and in IE 6 & 7 I get 0. Isn''t this supposed to return the height of the viewable area? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> alert(document.viewport.getHeight()); > -------------------------------------------------------- > In FF the alert says 8, and in IE 6 & 7 I get 0. Isn''t this supposed > to return the height of the viewable area?To get the full height of the window, including scrollable space, I''ve always used document.body.getDimensions().height or document.body.getHeight(). If you want just the height of the viewable area, you can use document.viewport.getDimensions().height or document.viewport.getHeight(). http://prototypejs.org/api/document/viewport document.body does not seem to be mentioned in the Prototype API docs, but it is just a regular Prototype extended element so all the methods that you can do on any other DOM element can also be done on document.body. -justin --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
If I change init to: function init() { if (navigator.appName == "Microsoft Internet Explorer"){ alert(document.body.offsetHeight); } else { alert(window.innerHeight); } } I do get the height of the viewport. document.viewport.getHeight() seems to tell me the height of the content within the viewport. B On May 8, 5:08 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > alert(document.viewport.getHeight()); > > -------------------------------------------------------- > > In FF the alert says 8, and in IE 6 & 7 I get 0. Isn''t this supposed > > to return the height of the viewable area? > > To get the full height of the window, including scrollable space, I''ve > always used document.body.getDimensions().height or > document.body.getHeight(). If you want just the height of the viewable > area, you can use document.viewport.getDimensions().height or > document.viewport.getHeight(). > > http://prototypejs.org/api/document/viewport > > document.body does not seem to be mentioned in the Prototype API docs, > but it is just a regular Prototype extended element so all the methods > that you can do on any other DOM element can also be done on > document.body. > > -justin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You are in a quirks mode. That''s why document.body acts as a document. Add a proper doctype and it should work as expected. Best, kangax On May 8, 5:42 pm, blechler <lech...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If I change init to: > > function init() { > if (navigator.appName == "Microsoft Internet Explorer"){ > alert(document.body.offsetHeight); > } else { > alert(window.innerHeight); > } > > } > > I do get the height of the viewport. > > document.viewport.getHeight() seems to tell me the height of the > content within the viewport. > > B > > On May 8, 5:08 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > alert(document.viewport.getHeight()); > > > -------------------------------------------------------- > > > In FF the alert says 8, and in IE 6 & 7 I get 0. Isn''t this supposed > > > to return the height of the viewable area? > > > To get the full height of the window, including scrollable space, I''ve > > always used document.body.getDimensions().height or > > document.body.getHeight(). If you want just the height of the viewable > > area, you can use document.viewport.getDimensions().height or > > document.viewport.getHeight(). > > >http://prototypejs.org/api/document/viewport > > > document.body does not seem to be mentioned in the Prototype API docs, > > but it is just a regular Prototype extended element so all the methods > > that you can do on any other DOM element can also be done on > > document.body. > > > -justin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---