Javascript Reference
Categories: DocumentFragment

javascript DocumentFragment Description

@June 18, 2009, 10:38 a.m.
DocumentFragment Firefox/Netscape/NN 6 IE n/a Chrome/Safari/DOM 1  

 

  

The W3C DOM DocumentFragment object is essentially a context-free container of other DOM nodes. In other words, you can use all node properties and methods to assemble a sequence of element and text nodes outside of the document tree, but not influenced by the containment that the DocumentFragment provides. If you then append or insert the DocumentFragment node into the document tree, the DocumentFragment container disappears, and its node contents stand on their own within the context of their position in the document tree. The DocumentFragment isn't necessary to assemble content that is wrapped by an element node, because the element node can act as both the temporary container outside the document tree and the container after insertion into the document tree. But if one or both ends of a content segment end in a text node, the DocumentFragment node provides a transparent bucket to keep the string of nodes together until they are dropped into the document.

 

Create an empty DocumentFragment container via the document.createDocumentFragment( ) method. A DocumentFragment type of node inherits all properties and methods of the Node object (for inserting and appending other nodes you create), and adds nothing of its own other than its silent ability to hold other nodes. Do not confuse a DocumentFragment node with a string of tagged text that gets assigned to the innerHTML property of an element. The W3C DOM (as of Level 2) provides no such string-to-node-hierarchy conversion.

 

Netscape 6 extends this node with a load( ) method that allows scripts to load XML documents into a plain (and unseen) Document node. Such a node is created via the document.implementation.createDocument( ) method. Scripts can then access the XML data in that document through regular W3C DOM document tree properties and methods.

 
Object Model Reference
 
documentFragmentNodeReference
 
Object-Specific Properties

None.

 
Object-Specific Methods

None.

 
Object-Specific Event Handler Properties

None.


Powered by Linode.