¹®¼ °èÅëµµ(hierarchy)·ÎºÎÅÍ °³Ã¼ÀÇ ÂüÁ¶¸¦ º¹»çÇÏ¿© Ä÷º¼ÇÀ̳ª °³Ã¼¸¦ ¹ÝȯÇÑ´Ù.
false | µðÆúÆ®À̸ç, º¹»çµÈ(Cloned) °³Ã¼´Â childNodes¸¦ Æ÷ÇÔÇÏÁö ¾Ê´Â´Ù. |
true | º¹»çµÈ(Cloned) °³Ã¼´Â childNodes¸¦ °®´Â´Ù. |
»õ·ÎÀÌ »ý¼ºµÈ ³ëµåÀÇ ÂüÁ¶ÇÏ´Â Ä÷º¼ÇÀ̳ª °³Ã¼¸¦ ¹ÝȯÇÑ´Ù.
cloneNode ¸Þ¼µå´Â °³Ã¼¿Í ¾ÖÆ®¸®ºäÆ®µé, ±×¸®°í ÁöÁ¤µÇ¾î ÀÖÀ¸¸é ÀÚ½Ä ³ëµåµé(childNodes)¸¦ º¹»çÇÑ´Ù.
º¹»ç(cloned) °³Ã¼ÀÇ ÀνÄÀÚ id¸¦ ÂüÁ¶ÇÏ´Â Ä÷º¼ÇÀ» ¹ÝȯÇÑ´Ù.
cloneNode ¸Þ¼µå´Â IFRAME¿¡¼ Á÷Á¢ÀûÀ¸·Î ÀÛ¿ëÇÏÁö ¾Ê´Â´Ù. ¾Æ·¡ ¿¹Á¦¿Í °°ÀÌ IFRAME¿¡¼ cloneNode ¸Þ¼µå¸¦ all Ä÷º¼ÇÀ» ÅëÇÏ¿© È£ÃâÇÏ¿©¾ß ÇÑ´Ù.
<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 °³Ã¼¿¡ Àû¿ëµÈ´Ù.
°³Ã¼ | script | IE |
---|
ÀÌ ¸Þ¼µå´Â (¿µ¹®)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>