Mega Code Archive

 
Categories / JavaScript Tutorial / Drag Drop
 

Get text object from dataTransfer defined the Drag and drop event

< html>     <head>         <title>System Drag And Drop Example</title>         <script type="text/javascript">             function handleDragDropEvent(oEvent) {                 switch(oEvent.type) {                     case "dragover":                     case "dragenter":                         oEvent.returnValue = false;                         break;                     case "drop":                         alert(oEvent.dataTransfer.getData("text"));                 }             }         </script>     </head>     <body>         <P>show you the selected text when dropped.</p>         <P><input type="text" value="drag this text" />         <input type="test"              ondragenter="handleDragDropEvent(event)"              ondragover="handleDragDropEvent(event)"              ondrop="handleDragDropEvent(event)"></input></p>     </body> </html>