The Methods of the Document Object

The methods of the document object allow you to do things that can’t be otherwise done.
Below is a table containing the methods of the document object and a short description of each method.

MethodDescription
attachEvent()Attaches a function to an event (IE only).
createAttribute()Creates an attribute with a name that is sent to it as a parameter.
createAttributeNS()Creates a new attribute in a particular name space.
createCDATASection()Creates a new CDATA section.
createComment()Creates a comment with a value that is sent to it as a parameter.
createDocumentFragment()Creates a new document fragment.
createElement()Creates an element of the type sent to it as a parameter.
createElementNS()Creates an element in a particular URI and a particular type sent to it as parameters.
createEntityReference()Creates a new entity reference.
createEvent()Creates an event.
createEventObject()Creates an event object for the purpose of passing event information.
createNodeIterator()Creates a node iterator object.
createNSResolver()Creates a name space resolver.
createProcessingInstruction()Creates a processing instruction.
createRange()Creates a range object.
createStyleSheet()Creates a style sheet for the document to use (IE only).
createTextNode()Creates a text string from the value sent to it as a parameter.
createTreeWalker()Creates a tree walker object.
detachEvent()Detaches a function from an event (IE only).
elementFromPoint()Returns the element object that appears at the location that is sent to it in two parameter values (pixels from left and pixels from top).
evaluate()Returns a result based on the parameters sent to it.
execCommand()Executes a command on the document when the document is in design mode.
getElementById()Returns a reference to the object with the ID attribute that is sent to it as a parameter.
getElementByClassName()Returns references to the elements with the class name that is sent to it as a parameter.
getElementByName()Returns references to the objects with the name attribute that is sent to it as parameter.
getElementByTagName()Returns references to the elements with the tag name that is sent to it as a parameter.
getElementByTagNameNS()Returns references to the elements with the tag name and name space that is sent to it as a parameter.
getSelection()Returns the value of a string of selected text in the document.
hasFocus()Returns a Boolean value based on whether or not the document has focus.
load()Loads an XML document.
mergeAttributes()Copies attributes from an object.
open()Opens a new document that allows you to write its contents using write() or writeIn() statements.
close()Closes a new document that has been opened with the open() method.
queryCommandEnable()Returns a Boolean value based on whether or not a command sent to it as a parameter can be executed.
queryCommandIndeterm()Returns a Boolean value based on whether or not a command sent to it as a parameter is in the indeterminate state.
queryCommandState()Returns a Boolean value based on whether or not a command sent to it as a parameter has executed.
queryCommandSupported()Returns a Boolean value based on whether or not a command sent to it as a parameter is supported.
queryCommandValue()Returns the current value of the document for the command that is sent to it as a parameter.
recalc()Recalculates the dynamic properties in a document.
releaseCapture()Releases the mouse capture from the document.
setActive()Sets an object as active but doesn’t give it focus.
write()Allows you to write a string of text into an HTML document.
writeln()Allows you to write a string of text into an HTML document but ends the line with a JavaScript newline character.

Leave a Reply