body | Firefox/Netscape/NN 6 IE 4 Chrome/Safari/DOM 1 |
| |
The body object reflects the
body element, which is distinct from the
document object. The body
object refers to just the element and its nested content. There can
be only one body element in an HTML page, so both the IE and W3C DOMs
provide a shortcut reference to the object,
document.body. Event handlers listed here appear
as attributes in the <body> tag, but in
truth are document-level events (best referenced in property form as
document.eventName).
While IE for the Mac doesn't share the sets of
client and scroll properties with all element objects, those
properties are defined for the body object.
|
|
In its effort to institute the standards-compatible mode in IE 6 for
Windows (see the DOCTYPE element), Microsoft has rendered useless the old
trick of using the body element's
clientHeight and clientWidth
properties to obtain the equivalent of Netscape's
window.innerHeight and
window.innerWidth properties. In
standards-compatibility mode (where
document.compatMode ==
"CSS1Compat"), you must use the
html element's
clientHeight and clientWidth
properties to find these values. Use these effective reference
shortcuts:
document.body.parentNode.clientHeight
document.body.parentNode.clientWidth
|
|
HTML Equivalent |
|
<body>
|
|
Object Model Reference |
|
[window.]document.body
|
|
Object-Specific Properties |
|
|
|
Object-Specific Methods |
|
|
|
Object-Specific Event Handler Properties |
|
|