Welcome to WebmasterWorld Guest from 188.8.131.52
Forum Moderators: incrediBILL
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
alert('h=' + document.body.clientHeight);
The clientHeight is 0. If removing the doctype or adding
at the very beginning, the clientHeight is right. Why the docType affects the clientHeight?
<?xml version="1.0" encoding="iso-8859-1"?>
Most (if not all?) browsers have a Quirks Mode and though they don't all render everything like IE while in Quirks Mode, Opera is close.
BUT one of the the main differences when your browser is rendering in Quirks Mode is that the BODY Element is the root element, so therefore is the same as the viewport as far as the initial containing block (ICB) is concerned, so if you were absolutely positioning something relative to the root you are using the BODY height/width co-ordinates.
however in Strict rendering mode the HTML element is the root element, the ICB, and if you're positiong absolutely to the viewport in this case it, the HTML element takes it height from the viewport and any positioning is done according to it's dimensions. The Body element in strict Mode will not have a height until you give it one.
Here's how I understand it -- in Standards Mode, all the window and scrolling measures as we knew them now have been assigned to the child of the documentElement object -- and these specific measures are no longer assigned to children of the body object, as they were in Quirks Mode.
So the values for these children of document.body are now assigned from the size of the document, rather than from the size of browser window. This makes good sense to me, even though we are accustomed to the previous arrangement and this newer one is a bit unsettling. In your example,for instance, there IS no content in the body, and therefore zero height.