D
David Mark
<FAQENTRY>
I think we've been over the various shortcomings of this:-
http://www.jibbering.com/faq/#getWindowSize
For one, it doesn't mention document.compatMode and it infers too much
from document.documentElement.clientHeight === 0 (width is a better
choice too). The feature test is aimed at one observed anomaly,
rather than trying to figure out which element represents the viewport
(i.e. has the scroll bars).
I recently pared down the version from My Library. Didn't lose
anything except support for margins on the HTML element (which would
obviously be an insane design). I have put a simplified test page and
explanations here:-
http://www.cinsoft.net/viewport.asp
I'm not saying it is perfect, but it is certainly a more robust design
than the current rendition. I am open to suggestions on the order of
tests and inferences made. Also, I'm sure some of the explanations
could be more clear.
Tested with IE7/8, Opera 8.54/9.27, Chrome, Windows Safari 4, FF 3.5
in all modes (with and without body borders),
I do note that IE8 has an unrelated bug (dealt with in the test page)
that causes an element at left 0,with an offsetWidth equal to the
documentElement (or body in quirks mode) clientWidth to create a 1px
horizontal overflow in some cases (have yet to pin down which cases).
Compatibility mode too and I am 100% sure that IE7 never behaved this
way. Very odd, but the fix is trivial.
Or, depending on the results of these tests and discussions, we could
revert back to the old article.
I think we've been over the various shortcomings of this:-
http://www.jibbering.com/faq/#getWindowSize
For one, it doesn't mention document.compatMode and it infers too much
from document.documentElement.clientHeight === 0 (width is a better
choice too). The feature test is aimed at one observed anomaly,
rather than trying to figure out which element represents the viewport
(i.e. has the scroll bars).
I recently pared down the version from My Library. Didn't lose
anything except support for margins on the HTML element (which would
obviously be an insane design). I have put a simplified test page and
explanations here:-
http://www.cinsoft.net/viewport.asp
I'm not saying it is perfect, but it is certainly a more robust design
than the current rendition. I am open to suggestions on the order of
tests and inferences made. Also, I'm sure some of the explanations
could be more clear.
Tested with IE7/8, Opera 8.54/9.27, Chrome, Windows Safari 4, FF 3.5
in all modes (with and without body borders),
I do note that IE8 has an unrelated bug (dealt with in the test page)
that causes an element at left 0,with an offsetWidth equal to the
documentElement (or body in quirks mode) clientWidth to create a 1px
horizontal overflow in some cases (have yet to pin down which cases).
Compatibility mode too and I am 100% sure that IE7 never behaved this
way. Very odd, but the fix is trivial.
Or, depending on the results of these tests and discussions, we could
revert back to the old article.