¹®¼­ °èÅëµµ(hierarchy)·ÎºÎÅÍ °³Ã¼ÀÇ ÂüÁ¶¸¦ º¹»çÇÏ¿© Ä÷º¼ÇÀ̳ª °³Ã¼¸¦ ¹ÝȯÇÑ´Ù.

Àμö/ÆĶó¸ÞÅÍ
bCloneChildren
¼±ÅÃÀûÀÎ ¿ä¼ÒÀ̸ç, ´ÙÀ½°ú °°Àº ºÎ¿ïÀ» ÁöÁ¤ÇÑ´Ù.
false µðÆúÆ®À̸ç, º¹»çµÈ(Cloned) °³Ã¼´Â childNodes¸¦ Æ÷ÇÔÇÏÁö ¾Ê´Â´Ù.
true º¹»çµÈ(Cloned) °³Ã¼´Â childNodes¸¦ °®´Â´Ù.
¹Ýȯ°ª objVal

»õ·ÎÀÌ »ý¼ºµÈ ³ëµåÀÇ ÂüÁ¶ÇÏ´Â Ä÷º¼ÇÀ̳ª °³Ã¼¸¦ ¹ÝȯÇÑ´Ù.

Ư±â

cloneNode ¸Þ¼­µå´Â °³Ã¼¿Í ¾ÖÆ®¸®ºäÆ®µé, ±×¸®°í ÁöÁ¤µÇ¾î ÀÖÀ¸¸é ÀÚ½Ä ³ëµåµé(childNodes)¸¦ º¹»çÇÑ´Ù.

º¹»ç(cloned) °³Ã¼ÀÇ ÀνÄÀÚ id¸¦ ÂüÁ¶ÇÏ´Â Ä÷º¼ÇÀ» ¹ÝȯÇÑ´Ù.

cloneNode ¸Þ¼­µå´Â IFRAME¿¡¼­ Á÷Á¢ÀûÀ¸·Î ÀÛ¿ëÇÏÁö ¾Ê´Â´Ù. ¾Æ·¡ ¿¹Á¦¿Í °°ÀÌ IFRAME¿¡¼­ cloneNode ¸Þ¼­µå¸¦ all Ä÷º¼ÇÀ» ÅëÇÏ¿© È£ÃâÇÏ¿©¾ß ÇÑ´Ù.

Ŭ¸¯ÇÏ¿© º¹»çÇÑ iFrame ³»¿ªÀ» º¸¶ó.
<IFRAME id="frameObjA" src="about:blank"
  style="border:solid 1px black; position:absolute; top:200px; left:660px; width:200px; height:100px;""></IFRAME>
<SCRIPT>
function doBegin(){
  var frameObjB=document.all.frameObjA.cloneNode();
  str='frameObjB.nodeName='+frameObjB.nodeName+'<BR>';
  str+='frameObjB.id='+frameObjB.id+'<BR>';
  str+='frameObjB.src='+frameObjB.src+'<BR>';
  str+='frameObjB.style.cssText=<FONT color=green size=-1>'+frameObjB.style.cssText+'</FONT><BR>';
  showA.innerHTML=str;
}
</SCRIPT>
<DIV id=showA onclick=doBegin()>Ŭ¸¯ÇÏ¿© º¹»çÇÑ iFrame ³»¿ªÀ» º¸¶ó.</DIV>

ÀÌ ¸Þ¼­µå´Â IE6ºÎÅÍ attribute °³Ã¼¿¡ Àû¿ëµÈ´Ù.

Àû¿ë
°³Ã¼scriptIE
ÂüÁ¶
appendChild removeNode replaceNode swapNode

ÀÌ ¸Þ¼­µå´Â (¿µ¹®)DOM1(W3C Document Object Model Level 1)¿¡¼­ Á¤ÀǵǾú´Ù.


¸Þ¼­µå ¿¹Á¦

oListÀÌ º¹»çµÇ¿© °°Àº ÀνÄÀÚÀÇ Ä÷º¼ÇÀ» ±¸¼ºÇÑ´Ù. ÆĶó¸ÞÅÍ true·Î Àڽĵé±îÁö º¹»çÇÑ´Ù.

<SCRIPT>
function fnClone(){
  var oCloneNode=oList.cloneNode(true);
  showB.insertBefore(oCloneNode);
  str='oList[0].id=<B>'+oList[0].id+'</B> oList[0].children.length=<B>'+oList[0].children.length+'</B><BR>';
  str+='oList[1].id=<B>'+oList[1].id+'</B> oList[1].children.length=<B>'+oList[1].children.length+'</B><BR>';
  str+='oCloneNode.nodeName='+oCloneNode.nodeName+'<BR>';
  str+='oCloneNode.length='+oCloneNode.children.length+'<BR>';
  for (i=0;i< oCloneNode.children.length;i++){
    str+='   '+i+'] '+oCloneNode.children[i].innerText+'<BR>';
  }
  showB.innerHTML=str;
  cloneButton.disabled=true;
}
</SCRIPT>
<UL id=oList>
<LI>¸ñ·Ï node 1
<LI>¸ñ·Ï node 2
<LI>¸ñ·Ï node 3
<LI>¸ñ·Ï node 4
</UL>
<INPUT id="cloneButton" type="button" value="Clone ¸ñ·Ï" onclick="fnClone()">
<DIV id=showB></DIV>