²ø¾î³õ±â(drag-and-drop) ÀÛ¾÷À» À§ÇÏ¿© »çÀü¿¡ Á¤ÀÇµÈ Å¬¸³º¸µå(clipboard)¿¡ Á¢¼ÓÀ» Çã¿ëÇÑ´Ù.
Script | [propVal=]..propName; | |
HTML | ¾ø´Ù. |
dataTransfer °³Ã¼´Â »ç¿ëÀÚ°¡ event °³Ã¼¸¦ ÅëÇÏ¿© ²ø¾î³õ±â ÀÛ¾÷À» Ä¿½ºÅ͸¶ÀÌ¡ÇÒ ¼ö ÀÖ°Ô ÇÑ´Ù.
dataTransfer °³Ã¼´Â ¿øº»°ú ¸ñÇ¥ À̺¥Æ®µé¿¡ »ç¿ëµÈ´Ù.
ÀüÇüÀûÀ¸·Î ¿øº» À̺¥Æ®¿¡¼ setData ¸Þ¼µå¸¦ »ç¿ëÇÏ¿© À̵¿½ÃÅ°´Â µ¥ÀÌÅÍÀÇ Á¤º¸¸¦ Á¦°øÇÏ°í,
¸ñÇ¥ À̺¥Æ®ÀÇ getData ¸Þ¼µå¸¦ »ç¿ëÇÏ¿© ¾î¶² µ¥ÀÌÅ͸¦ ¾î¶² ¾ç½ÄÀ¸·Î ÇÒ °ÍÀΰ¡¸¦ °áÁ¤ÇÑ´Ù.
IE5 ºÎÅÍ´Â ½ºÅ©¸³Æ®¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.
°³Ã¼ | script | HTML | ±Ô°Ý | IE |
---|
¼³¸íÀ» À§ÇÑ ¿¹Á¦
¿øº» ¾ØÄ¿ ű×
ºÙ¿©³ÖÀ» ¸ñÇ¥ Áö¿ª
°á°ú Ç¥½Ãâ |
|
¿øº» ¾ØÄ¿ ÅÂ±× ºÎºÐÀ» µå·¡±×Çؼ ¹ÝÀü½ÃÅ°°í, µå·¡±×ÇÏ¿© ¸ñÇ¥ Áö¿ª¿¡ ºÙ¿©³Ö±âÇ϶ó. event.dataTransfer.setData('URL',sourceObj.href);¿¡¼ ¿øº» °³Ã¼ÀÇ ÁÖ¼Ò¸¦ URL·Î Àü¼ÛÇÔÀ» ¼³Á¤ÇÑ´Ù.event.dataTransfer.getData('URL');¿¡¼ ¹Þ´Â µ¥ÀÌÅ͸¦ ÁÖ¼Ò(URL)·Î ¹Þ´Â´Ù. |
|
<SCRIPT> UrlStr=oObj=''; function dragStart(){ event.dataTransfer.setData('URL',sourceObj.href); oObj=event.dataTransfer; str='<DL><DT>ondragstart<DD>oObj.dropEffect='+oObj.dropEffect+'</DD>'; str+='<DD>oObj.effectAllowed='+oObj.effectAllowed+'</DD>'; } function FinishDrag(){ targetObj.innerText=event.dataTransfer.getData('URL'); oObj=event.dataTransfer; str+='<DT>ondragenter<DD>oObj.dropEffect='+oObj.dropEffect+'</DD>' swdropEffect.innerText=oObj.dropEffect; str+='<DD>oObj.effectAllowed='+oObj.effectAllowed+'</DD></DL>'; sweffectAllowed.innerText=oObj.effectAllowed; showA.innerHTML=str; } </SCRIPT> <DIV stype=padding:5> <A id="sourceObj" href="#sampleJump" onclick="return(false)" ondragstart="dragStart()" style="border:solid 1 blue;padding:3">¿øº» ¾ØÄ¿ ű×</A> <SPAN style=width:1em></SPAN> <SPAN id=targetObj ondragenter="FinishDrag()" style="border:solid 1 blue;padding:3">ºÙ¿©³ÖÀ» ¸ñÇ¥ Áö¿ª</SPAN> </DIV> <DIV id=showA style=margin-top:5;padding:3;color:blue>°á°ú Ç¥½Ãâ</DIV> |