Javascript Reference
Categories: BODY

javascript BODY Description

@March 15, 2008, 1:22 a.m.
bodyFirefox/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
 
alinkbackgroundbgColorbgPropertiesbottomMargin
leftMarginlinknoWraprightMarginscroll
texttopMarginvLink
 
Object-Specific Methods
 
createTextRange( )
 
Object-Specific Event Handler Properties
 
HandlerIE WindowsIE MacFirefox/Netscape/NNW3C DOM
onafterprint5n/an/an/a
onbeforeprint5n/an/an/a
onbeforeunload4n/an/an/a
onload33.0122
onselectn/an/a6n/a
onunload33.0122

Powered by Linode.