Document Methods and Properties

The methods and properties in this section are implemented for the document object. Methods and properties already covered in the previous section are not repeated again.

Methods

Method

Description

clear()

Empties the document

close()

Ends the write access to the document

createAttribute(attribute)

Creates an attribute with the given name

createDocumentFragment()

Creates a document fragment

createElement(name)

Creates an element with the given tag name

createTextNode(text)

Creates a text node with the given text

getElementById(id)

Returns the element with the given ID

getElementsByName(name)

Returns all elements with the given name

open(mime, replace)

Opens the document for write access, sets the MIME type, and if the optional replace parameter is true, replaces the old contents (otherwise, appends data)

write(text)

Writes data to the document

writeln(text)

Writes data and a linefeed (\r\n) to the document

Properties

Property

Description

alinkColor

Color for active links

anchors[]

List of all anchors in the document

applets[]

List of all Java applets in the document

bgColor

Background color of the document

body

Body portion of the document

compatMode

Whether the rendering engine uses a compatibility mode for older content

cookie

Cookies the document can access

documentElement

DOM node for the document

domain

Domain of the document ...

Get Programming Atlas now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.