Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / February 2005



Tip: Looking for answers? Try searching our database.

Obtaining window height and width

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Beall - 27 Feb 2005 19:06 GMT
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
Martin Honnen - 27 Feb 2005 19:14 GMT
> And I know that if those are undefined (meaning you are probably dealing
> with IE), you can try:
[quoted text clipped - 8 lines]
> 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.

Signature

    Martin Honnen
    http://JavaScript.FAQTs.com/

Chris Beall - 27 Feb 2005 19:41 GMT
>> 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
RobG - 27 Feb 2005 22:44 GMT
[...]
> 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>

Signature

Rob

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.