Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

cloneNode method

Copies a reference to the object from the document hierarchy.

Document Object Model (DOM) Level 3 Core Specification, Section 1.4

Syntax


IHTMLDOMNode retVal = object.cloneNode(fDeep);

Parameters

fDeep [in, optional]

Type: VARIANT_BOOL

VARIANT_BOOL that specifies one of the following values:

VARIANT_FALSE (FALSE)

Cloned objects do not include childNodes.

VARIANT_TRUE (TRUE)

Cloned objects include childNodes.

Standards information

Remarks

The IHTMLDOMNode::cloneNode method copies an object, attributes, and, if specified, the childNodes.

When you refer to the IHTMLElement::id of a cloned element, a collection is returned.

IHTMLDOMNode::cloneNodedoes not work on an IFRAME directly. You must call IHTMLDOMNode::cloneNodethrough the all collection. The following example demonstrates how to call IHTMLDOMNode::cloneNode on an IFRAME.


<!DOCTYPE html>

<html>

<body>
  <iframe id="oFrame" src="about:blank"
    style="border: 1px solid black; position: absolute; top: 20px; left: 30px; width: 350px; height: 300px;">
  </iframe>
  <script>
    var iframeClone = document.getElementById('oFrame').cloneNode();
    console.log(iframeClone);
  </script>
</body>
</html>

If the object being cloned is an element and that element has expandos defined on it, the expandos are copied to the clone when IHTMLDOMNode::cloneNode is called. Other browsers might handle this differently.

In Microsoft Internet Explorer 6, this method applies to the attribute object.

See also

Reference
IHTMLDOMNode::appendChild
IHTMLDOMNode::removeNode
IHTMLDOMNode::replaceNode
IHTMLDOMNode::swapNode

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.