Re: does getDimensions actually work?

blechler
Thu, 08 May 2008 21:42:43 -0000

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