Cookies improve the way our website works, by using this website you are agreeing to our use of cookies. For more information see our privacy policy.
OK
Specifies or retrieves the type of the drag-and-drop operation.
Note: The dataTransfer object and its dropEffect property are supported in Firefox from version 3.5.
The value of the dropEffect property also affects the style of the displayed cursor.
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 allowed types of a drag-and-drop operation can be set with the effectAllowed 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.
String that sets or retrieves the type of the operation.
One of the following values:
copy
Copy operation with copy cursor.
link
Link operation with link cursor.
move
Move operation with move cursor.
none
No-drop cursor is displayed.
Default: none.
Example HTML code 1:
This example illustrates the use of the dropEffect property:
<head><scripttype="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.");
return;
}
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;
}
}
</script></head><body><tablecellpadding="5px"cellspacing="5px"><tr><td>
Please select the allowed drag effect:
<selectid="dragEffect"><optionvalue="none">none</option><optionvalue="copy">copy</option><optionvalue="move">move</option><optionvalue="link">link</option><optionvalue="copymove">copymove</option><optionvalue="copylink">copylink</option><optionvalue="linkmove">linkmove</option><optionvalue="all">all</option></select></td><td>
Please select the allowed drop effect:
<selectid="dropEffect"><optionvalue="none">none</option><optionvalue="copy">copy</option><optionvalue="move">move</option><optionvalue="link">link</option></select></td></tr><tr><tdondragstart="SetDragEffect (event)"style="background-color:#e0b0f0;">
Select some text and drag that!
</td><tdondragstart="return false;"ondragover="SetDropEffect (event); return false;"ondragenter=" return false;"ondrop="GetDroppedItem (event);"style="background-color:#b0e0f0;">
Try to drop the selected text here!
</td></tr></table><divstyle="margin-top:30px; width:200px; height:50px; background-color:#b0f0e0;">
The dropped text:
<divid="info"></div></div></body>