Obtaining window height and width

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Beall

    Obtaining window height and width

    OK, I know that for many browsers, window height and width can be
    obtained from:
    window.outerHei ght and window.innerHei ght
    window.outerWid th and window.innerWid th

    And I know that if those are undefined (meaning you are probably dealing
    with IE), you can try:
    document.body.c lientHeight
    document.body.c lientWidth

    But I've determined that those work only if IE is old or in quirks mode.
    For IE 6 with a proper DOCTYPE defined, the values reported are exactly
    what they say they are: the height and width of the DOCUMENT, regardless
    of the window size.

    Is there a way to obtain the window size from IE 6 when a DOCTYPE has
    been specified on the page?

    Thanks,
    Chris Beall

  • Martin Honnen

    #2
    Re: Obtaining window height and width



    Chris Beall wrote:

    [color=blue]
    > And I know that if those are undefined (meaning you are probably dealing
    > with IE), you can try:
    > document.body.c lientHeight
    > document.body.c lientWidth
    >
    > But I've determined that those work only if IE is old or in quirks mode.
    > For IE 6 with a proper DOCTYPE defined, the values reported are exactly
    > what they say they are: the height and width of the DOCUMENT, regardless
    > of the window size.
    >
    > Is there a way to obtain the window size from IE 6 when a DOCTYPE has
    > been specified on the page?[/color]

    If document.body.c lientWidth/Height are what you are using with IE then
    with IE 6 in strict mode you want
    document.docume ntElement.clien tWidth/Height.

    --

    Martin Honnen

    Comment

    • Chris Beall

      #3
      Re: Obtaining window height and width

      Martin Honnen wrote:
      [color=blue]
      >
      >
      > Chris Beall wrote:
      >
      >[color=green]
      >> Is there a way to obtain the window size from IE 6 when a DOCTYPE has
      >> been specified on the page?[/color]
      >
      >
      > If document.body.c lientWidth/Height are what you are using with IE then
      > with IE 6 in strict mode you want
      > document.docume ntElement.clien tWidth/Height.
      >[/color]
      Martin,

      That seems to do the trick. Perverse that the IE folks persist in
      calling this a property of the document rather than the window, but...

      For anyone lurking, the values Martin provided correspond to the INNER
      height and width of the window, i.e. the space available for display of
      the document after accounting for scroll and tool bars, etc.

      Many thanks,
      Chris Beall

      Comment

      • RobG

        #4
        Re: Obtaining window height and width

        Chris Beall wrote:
        [...][color=blue]
        > For anyone lurking, the values Martin provided correspond to the INNER
        > height and width of the window, i.e. the space available for display of
        > the document after accounting for scroll and tool bars, etc.[/color]

        For further information, you may want to follow the "viewport"
        link here:

        <URL:http://www.quirksmode. org/index.html>


        --
        Rob

        Comment

        Working...