Mega Code Archive

 
Categories / JavaScript Tutorial / Drag Drop
 

Drop target events fire now

< html>     <head>         <title>System Drag And Drop Example</title>         <script type="text/javascript">             function handleDragDropEvent(oEvent) {                 var oTextbox = document.getElementById("txt1");                 oTextbox.value +=  oEvent.type + "\n";                 switch(oEvent.type) {                     case "dragover":                     case "dragenter":                         oEvent.returnValue = false;                 }             }         </script>     </head>     <body>         <P>Try dragging the text from the textbox to the red square.         Drop target events fire now.</p>         <P>drag me</p>         <div style="background-color: red; height: 100px; width: 100px"              ondragenter="handleDragDropEvent(event)"              ondragover="handleDragDropEvent(event)"              ondragleave="handleDragDropEvent(event)"              ondrop="handleDragDropEvent(event)"></div></p>         <P><textarea rows="10" cols="25" readonly="readonly" id="txt1"></textarea></p>     </body> </html>