Re: does getDimensions actually work?

Justin Perkins
Thu, 08 May 2008 21:08:00 -0000

>  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