This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

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.

Method of dom/Rangedom/Range

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 codeDescription
S_OKThe operation completed successfully.
InvalidStateErrordetach has been invoked on the object.
W3Exception_DOM_HIERARCHY_REQUEST_ERRA 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