Obtaining window height and width

Discussion in 'Javascript' started by Chris Beall, Feb 27, 2005.

  1. Chris Beall

    Chris Beall Guest

    OK, I know that for many browsers, window height and width can be
    obtained from:
    window.outerHeight and window.innerHeight
    window.outerWidth and window.innerWidth

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

    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
    Chris Beall, Feb 27, 2005
    #1
    1. Advertising

  2. Chris Beall wrote:


    > And I know that if those are undefined (meaning you are probably dealing
    > with IE), you can try:
    > document.body.clientHeight
    > document.body.clientWidth
    >
    > 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?


    If document.body.clientWidth/Height are what you are using with IE then
    with IE 6 in strict mode you want
    document.documentElement.clientWidth/Height.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Feb 27, 2005
    #2
    1. Advertising

  3. Chris Beall

    Chris Beall Guest

    Martin Honnen wrote:

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

    >
    >
    > If document.body.clientWidth/Height are what you are using with IE then
    > with IE 6 in strict mode you want
    > document.documentElement.clientWidth/Height.
    >

    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
    Chris Beall, Feb 27, 2005
    #3
  4. Chris Beall

    RobG Guest

    Chris Beall wrote:
    [...]
    > 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.


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

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


    --
    Rob
    RobG, Feb 27, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AndrewF
    Replies:
    1
    Views:
    733
    Bruce Barker
    Oct 10, 2005
  2. Lois
    Replies:
    1
    Views:
    3,171
    Ryan Stewart
    Dec 27, 2004
  3. cera
    Replies:
    1
    Views:
    1,237
    Neredbojias
    Aug 18, 2007
  4. Bernd Meier
    Replies:
    6
    Views:
    495
    GTalbot
    Jan 14, 2008
  5. Sharlet

    Obtaining Width and Height for an Image

    Sharlet, Aug 7, 2003, in forum: ASP General
    Replies:
    5
    Views:
    92
    Chris Barber
    Aug 8, 2003
Loading...

Share This Page