Get text object from dataTransfer defined the Drag and drop event : Drag Drop Event : Drag Drop JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Drag Drop » Drag Drop Event »

 

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>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Drag Drop
» Drag Drop Event