Obtaining window height and width

C

Chris Beall

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
 
M

Martin Honnen

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.
 
C

Chris Beall

Martin said:
Chris Beall wrote:




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
 
R

RobG

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>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top