When searching for a method for determining the height of a window, I found out that "document.body.clientHeight" is useful. I tried it in different situations, everything failed. Failed means that it returns the same value at all window heights.
Finally, I deleted the DOCTYPE ad
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
and everything went fine. Now it returns the exact result.
Even html5 DOCTYPE
<!DOCTYPE html>
returns an invalid result.
I tested it in different browsers (Chrome, Opera, Firefox and IE).
What is the reason for this? Are there any other restrictions when using document.body? Are there other things (variables, tags, methods, usage, etc.) for the same scenario?
Thank.
source
share