Home > Element Reference : XUL Document

Contents

### XUL Document

Accessible through the global document object. Most of the createX methods are not implemented in Mozilla for XUL documents.

#### Properties and Methods:

addBinding ( elem , url )

Adds the binding pointed to by the given URL to an element in the document.

addEventListener ( type , listener , capture ) DOM2

Adds a new event listener for the event specified by type to the document. The type should be the same as the attribute event handler without the 'on' prefix, for example 'click' or 'keydown'. The listener is the name of a function. If capture is set to true, the event will capture.

characterSet

The character set of the document.

commandDispatcher
contentType
createAttribute ( name ) DOM0

Creates a new attribute object and returns it. This will be a DOM Attr object. If you want to add a new attribute to an element, you should use setAttribute on the element. This is not implemented in Mozilla for XUL documents.

createAttributeNS ( namespace, name ) DOM2

Creates a new attribute object with a different namespace than the default and returns it. The namespace argument should be the URI of the namespace. This is not implemented in Mozilla for XUL documents.

createCDATASection ( data ) DOM0

Creates a new CDATA node for a document and returns it. This is not implemented in Mozilla for XUL documents.

createComment ( data ) DOM0, Moz0.9.4

Creates a new comment node within a document and returns it.

createDocumentFragment ( ) DOM0

Creates a new document fragment and returns it. This is not implemented in Mozilla for XUL documents.

createElement ( name ) DOM0

Creates a new element. The one argument is the name of the tag for the element that you want to create. This function would be used to add new rows new menus and trees. The function returns the created element which you can then add anywhere into the document.

createElementNS ( namespace , name ) DOM2

Creates a new element similar to createElement but allows you to specify a namespace. The namespace argument should be the URI of the namespace.

createEntityReference ( name ) DOM0

Creates and returns a new entity reference node. This is not implemented in Mozilla for XUL documents.

createEvent ( type )

Creates a new Event object of the given type (such as mousedown). The event can then be sent to an element using the dispatchEvent function.

createNodeIterator ( rootNode , whatToShow, filter, entityReferenceExpansion ) DOM0

Creates a NodeIterator object which can be used to iterate over the nodes of a document. You can filter out types of elements using the whatToShow and filter properties. You can force entities to be expanded using the last parameter. This is not currently implemented in Mozilla.

createProcessingInstruction ( target , data ) DOM0

Creates a new processing instruction node and returns it. Processing instructions are the tags that are surrounded by question marks.

createRange ( )

Creates a range object which can be used to select and extract portions of a document.

createTextNode ( data ) DOM0

Creates a new text node and returns it. This can be used if you want to modify the text inside a tag, for example inside the html element.

createTreeWalker ( rootNode , whatToShow, filter, entityReferenceExpansion ) DOM2, Moz0.9.5

Creates a TreeWalker object which can be used to iterate over the nodes of a document. You can filter out types of elements using the whatToShow and filter properties. You can force entities to be expanded using the last parameter.

defaultView DOM2

The view for the document, which will typically refer to the window object for the document.

dispatchEvent ( event ) DOM2

Sends an event to the document.

doctype DOM0

Returns the doctype of the document. In HTML this is specified with the doctype declaration often found at the top of the document. This property is read only.

documentElement DOM0

Returns an Element object for the document body.

getAnonymousElementByAttribute ( elem , attrib , value )

For a given element specified by the first argument, the anonymous element in its binding with the attribute set to a particular value is returned. Unlike getElementsByAttribute, it only returns one element.

getAnonymousNodes ( elem )

This method will return an array of the direct anonymous children of the element passed in as the argument elem. The element in the first position of the array is the first child as defined in the content tag of the XBL definition.

getBindingParent ( elem )

Returns the element that an element in a binding is bound to. This is the reverse of getAnonymousNodes.

getBoxObjectFor
getElementById ( id ) DOM0

Returns the element within the document that has the given id. This is a common way to retrieve references to elements in a document.

getElementsByAttribute ( attrib , value )

Returns an array of all the elements in the document that have the attribute given by the first argument attrib set to the value given by the second argument val. The following example will return all of the checked items in the document.

var elems=document.getElementsByAttribute("checked","true");

getElementsByTagName ( name ) DOM0

Returns an array of all the child elements of the document that have the given tag name.

getElementsByTagNameNS ( namespace , name ) DOM2

Returns an array of all the child elements of the document that have the given tag name and the given namespace. The namespace argument should be the URI of the namespace.

height

The height of the document.

implementation DOM0

Returns the DOMImplmentation object for the document which can be used to create new documents and determine what DOM features are supported.

importNode ( importedNode , deep ) DOM2

Uses to copy a node from another document into this document. If the deep argument is true, child nodes are also imported.

loadBindingDocument ( url )

Loads the content of the URL which is expected to be an XBL document and returns it. This can be used to cache the bindings contained within it.

persist ( id , attrib )

Marks the attribute attrib on the element within the document with the given id as persistent. The value will retain its value after the window is closed.

popupNode

Holds a reference to the element that has the current popup window open. For example, if a box has a context menu associated with it, the value of document.popupNode with hold a reference to the box element. The value of this property is not cleared when the popup is closed. Thus, popupNode will still hold a reference to the box even after the popup is closed.

removeBinding ( elem , url )

Removes the binding pointed to by the given URL from an element in the document. Nothing happens if the binding is not applied to the element.

removeEventListener ( type , listener , capture ) DOM2

Removes an event listener from the document. The listener specified by the type and listener argument is removed.

setBoxObjectFor
tooltipNode

Holds a reference to the element that has the current tooltip open. For example, document.tooltipNode will hold a reference to the toolbar button when its tooltip is displayed. If no tooltip is displayed, this value will be null.

width

The width of the document.

Copyright (C) 1999 - 2002 XULPlanet.com