cloneContents
Summary
Returns a document fragment containing the nodes of a range. If any nodes are partially selected, their start or end nodes are included.
Syntax
var object = object.cloneContents(/* see parameter list */);
Parameters
oDocumentFragment
- Data-type
- any
Returns a document fragment object.
Return Value
Returns an object of type DOM NodeDOM Node
Type: HRESULT
This method can return one of these values.
Return code | Description |
---|---|
S_OK | The operation completed successfully. |
InvalidStateError | detach has been invoked on the object. |
W3Exception_DOM_HIERARCHY_REQUEST_ERR | A document type node is included in the range that is being cloned. |
Examples
var range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
var documentFragment = range.cloneContents();
document.body.appendChild(documentFragment);
Syntax
documentFragment = range.cloneContents();
Standards information
Attributions
Mozilla Developer Network : [Range.cloneContents Article]
Microsoft Developer Network: [cloneContents Method Article]