You are here: Reference > JavaScript > client-side > event handling > properties > effectAllowed (dataTransfer)

effectAllowed property (dataTransfer)

Browser support:
Specifies or retrieves the allowed types of the current drag-and-drop operation.
Note: The dataTransfer object and its effectAllowed property are supported in Firefox from version 3.5.
The type of a drag-and-drop operation depends on the allowed types of data transfer and the operation type specified with the dropEffect property. The dropEffect property specifies the actual type of the drag-and-drop operation, but if it is not allowed, the dragged content cannot be dropped.

It is advisable to specify the allowed types of transfer at the start point of the drag, in a handler for the ondragstart event. Each drop target element can specify its own operation type with the dropEffect property. If the dropEffect property is not specified, the operation type depends on the value of the effectAllowed property, the current platform and the use of platform specific modifier keys during dragging.

If you want to set the operation type for an element, modify the value of the dropEffect property in a handler for the ondragenter and ondragover events.


You can find the related objects in the Supported by objects section below.
This property is read/write.

Possible values:

String that specifies or retrieves the type of the effect to allow.
One of the following values:
The dragged content can be copied, moved and linked.
The dragged content can be copied.
The dragged content can be copied and linked.
The dragged content can be copied and moved.
The dragged content can be linked.
The dragged content can be linked and moved.
The dragged content can be moved.
The dragged content cannot be dropped and the no-drop cursor is displayed during dragging.
Default. The effectAllowed property is not initialized. The default behavior is 'move' for editable elements, 'link' for anchors and 'copy' for other elements.
Default: uninitialized.

Example HTML code 1:

This example illustrates the use of the effectAllowed property:
    <script type="text/javascript">
        function SetDragEffect (event) {
            if (event.dataTransfer) {
                var dragEffect = document.getElementById ("dragEffect");
                event.dataTransfer.effectAllowed = dragEffect.value;

        function SetDropEffect (event) {
            if (event.dataTransfer) {
                var dropEffect = document.getElementById ("dropEffect");
                event.dataTransfer.dropEffect = dropEffect.value;

        function GetDroppedItem (event) {
            if (!event.dataTransfer) {
                alert ("Your browser does not support the dataTransfer object.");
            var transferObj = event.dataTransfer;
            var textData = transferObj.getData ("Text");

            var info = document.getElementById ("info");
            if ('textContent' in info) {
                info.textContent = textData;
            else {
                info.innerText = textData;
    <table cellpadding="5px" cellspacing="5px">
                Please select the allowed drag effect:
                <select id="dragEffect">
                    <option value="none">none</option>
                    <option value="copy">copy</option>
                    <option value="move">move</option>
                    <option value="link">link</option>
                    <option value="copymove">copymove</option>
                    <option value="copylink">copylink</option>
                    <option value="linkmove">linkmove</option>
                    <option value="all">all</option>
                Please select the allowed drop effect:
                <select id="dropEffect">
                    <option value="none">none</option>
                    <option value="copy">copy</option>
                    <option value="move">move</option>
                    <option value="link">link</option>
            <td ondragstart="SetDragEffect (event)" style="background-color:#e0b0f0;">
                Select some text and drag that!
            <td ondragstart="return false;" ondragover="SetDropEffect (event); return false;" ondragenter=" return false;"
                 ondrop="GetDroppedItem (event);"
                Try to drop the selected text here!
    <div style="margin-top:30px; width:200px; height:50px; background-color:#b0f0e0;">
        The dropped text:
        <div id="info"></div>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content