JavaScript Reference :: Document

The document object is created automatically by the browser when a BODY tag is present.

methods

void captureEvents(string eventType)
Captures and handles the event type specified.
void close()
Closes the document to writing.
Node createElement(string htmlTag)
Creates an HTML element and returns it as a DOM node.
Node createTextNode()
Creates a text node and returns it.
Node getElementById(string id)
Retrieves and returns a node reference to the HTML element specified in the parameter.
NodeList getElementsByName(string name)
Returns a node list of elements with the name specified.
NodeList getElementsByTagName(string htmlTag)
Returns a NodeList containing all instances in the document of the specified element.
string getSelection()
Returns the text selected in the document.
void handleEvent(string eventType)
Calls the event handler for the specified event.
void open()
Opens a document for writing.
void releaseEvents(string eventType)
Releases the specified event type to be handled further down the event hierarchy.
void routeEvent(string eventType)
Routes the event along the normal event hierarchy.
object toSource()
Returns a literal representing the source code of the object e.g "function Object() { [native code] }" or "function Car(manufactuer, model, productionyear) { this.make = manufactuer; this.model = model; this.year = productionyear; }".
string toString()
Returns a string representing the object i.e. "[object Object]".
void unwatch(property)
Removes a previously set watchpoint.
								
object valueOf()
Returns the primitive value of the object e.g. "function Object() { [native code] }".
void watch(property, handlingFunction)
Calls the handlingFunction when the property is changed.
								
void write(string)
Writes the string to the document object.
void writeLn(string)
Writes the string to the document object, followed by a newline.

properties

alinkColor
The color for active links in the document.
anchors
An array of all anchor objects in the document.
applets
An array of all applet objects in the document.
bgColor
The background color of the document.
constructor
The constructor method is the base method used to create an instance of the object.
cookie
The cookie created for the document.
domain
The name of the server from which the document originated.
embeds
An array of objects embedded in the document.
fgColor
The color specified for the foreground. Corresponds to the color property in a style rule.
forms
An array of Form objects created by form tags contained in the document.
ids
An array of id attributes in the document.
images
An array of Image objects created by image tags contained in the document.
lastModified
The date the file was last modified.
layers
An array containing all the Layer objects in the document.
linkColor
The default color specified for anchor objects in the document.
links
An array containing all the Area and Layer objects in the document.
plugins
The Plugins object.
prototype
Exposes the prototype for the method or property of the object.
referrer
The URL of the document visited prior to the current document.
title
The title specified in the title tag.
URL
The location of the document.
vlinkColor
The color specified for visited links in the document.

events

onclick
ondblclick
onerror
onkeydown
onkeypress
onkeyup
onload
onmousedown
onmouseout
onmouseover
onmouseup
onresize
onunload