Mega Code Archive

 
Categories / JavaScript Tutorial / Drag Drop
 

Get URL 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("URL"));                 }             }         </script>     </head>     <body>         <P>Try dragging the link to the red square.         It will show you the URL when dropped.</p>         <P><a href="http://www.rntsoft.com">www.rntsoft.com</a>         <input type="text"              ondragenter="handleDragDropEvent(event)"              ondragover="handleDragDropEvent(event)"              ondrop="handleDragDropEvent(event)"></div></p>     </body> </html>