TOC PREV NEXT INDEX

domref



body


body returns the BODY node of the current document.

Syntax

bodyObj = document.body
 
document.body = aNewBodyElement
 

Parameters

bodyObj is a node representing the BODY or FRAMESET element in the current document.

aNewBodyElement is a BODY or FRAMESET element that will replace the current BODY or FRAMESET element

Example

// in HTML: <body id="oldBodyElement"></body>
 
alert(document.body.id); // "oldBodyElement"
 
var aNewBodyElement = document.createElement("body");
 
aNewBodyElement.id = "newBodyElement";
 
document.body = aNewBodyElement;
 
alert(document.body.id); // "newBodyElement" 
 

Notes

body is the element that contains the content for the document. In documents with BODY contents, returns the BODY element, and in frameset documents, this returns the outermost FRAMESET element.

Though body is settable, setting a new body on a document will effectively remove all the current children of the existing BODY element.

Specification

body
 


Netscape Communications
http://developer.netscape.com
TOC PREV NEXT INDEX