O'Reilly logo

Programming Atlas by Christian Wenz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required