You are here: Reference > JavaScript > client-side > event handling > methods > dragDrop

dragDrop method

Browser support:
Initiates a drag-and-drop operation.
A call to the dragDrop method fires the ondragstart event.


object.dragDrop ( );
You can find the related objects in the Supported by objects section below.

Return value:

Boolean. One of the following values:
false The dragged content was not dropped.
true The dragged content has been successfully dropped.

Example HTML code 1:

This example illustrates the use of the dragDrop method:
    <script type="text/javascript">
        function InitDrag (elem) {
                // if right mouse button is down
            if (event.button & 2) {
                elem.dragDrop ();
    <div onmousedown="InitDrag (this)" style="background-color:#e0d0a0; width:200px">
        Select some text in this field and use the right mouse button for dragging!
    <br /><br />
    <div style="background-color:#a0d0e0; width:200px">
        Dragging with the right mouse button is not allowed for this field!
    <br /><br />
    <textarea rows="5">The dragged text can be dropped into this field.</textarea>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content