cloneNode method
Copies a reference to the object from the document hierarchy.
![]() |
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.
<HTML>
<SCRIPT>
function fnBegin(){
var fr = document.all.oFrame.cloneNode();
console.log(document.body.innerHTML);
}
</SCRIPT>
<BODY onload="fnBegin()">
<IFRAME id="oFrame" src="about:blank"
style="border:1px solid black; position:absolute; top:20px; left:30px;
width:350px; height:300px;"></IFRAME>
</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
Build date: 11/12/2012
