By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,258 Members | 1,679 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,258 IT Pros & Developers. It's quick & easy.

Obtaining window height and width

P: n/a
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

Jul 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a


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/
Jul 23 '05 #2

P: n/a
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

Jul 23 '05 #3

P: n/a
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
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.