topical media & game development

talk show tell print

professional-javascript-13-SystemDragAndDropExample10.htm / htm



  <html>
      <head>
          <title>System Drag And Drop Example</title>
          <script type="text/javascript">
          
              function handleMouseMove(oEvent) {
                  if (oEvent.button == 1) {
                      oEvent.srcElement.dragDrop();
                  }
              }
              
              function handleDragDropEvent(oEvent) {
                  oEvent.dataTransfer.setData("text", "This is a red square");
              }                        
          </script>
      </head>
      <body>
          <p>Try dragging the red square into the textbox.</p>
          <p><div style="background-color: red; height: 100px; width: 100px"
                  onmousemove="handleMouseMove(event)" 
                  ondragstart="handleDragDropEvent(event)">This is a red square</div> </p>
          <p><input type="text" value="" /></p>
      </body>
  </html>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.