Ticket #9331 (closed bug: cantfix)
$(document).width(), $(document).height() unreliable in IE6, 8 and 9
|Reported by:||_michael||Owned by:|
$(document).width() and $(document).height() don't always report the true document size. Return values will include the width of the scrollbar if exactly one scrollbar is present (IE6, 8, 9). In addition, they will be off by 4px if the content area is smaller than the viewport (IE6, 8).
The likely cause: The figures returned by document.documentElement.offsetWith and .offsetHeight include elements of the browser chrome (scrollbars; in IE6/8, a 2px border around the viewport). These figures confuse the result calculated by jQuery.
I've seen the problem a while ago in jQuery 1.3.2, and it is still there in 1.5.2 and 1.6.1. Windows XP through Windows 7.
Here's a blog post with more details if you need them, including a demo and a temporary workaround.
Bug #8048 seems to be another manifestation of this problem, although it's a special case.