JavaScript Reference/Javascript Properties/dropEffect

Материал из Web эксперт
Перейти к: навигация, поиск

"dropEffect" Example

<!-- 
Example revised from 
The Web Programmer"s Desk Reference
by Lazaro Issi Cohen and Joseph Issi Cohen 
ISBN: 1593270119
Publisher: No Starch Press 2004
-->     
<html>
<head>
<script language="JavaScript">
function transferDrop() {
    window.event.srcElement.innerText = window.event.dataTransfer.getData("text");
    window.event.returnValue = false; 
} 
function transferDrag() { 
    window.event.dataTransfer.dropEffect = "move"; 
    window.event.returnValue = false; 
} 
</script>
</head>
<body bottommargin="150">
<p id="mySource" 
   ondragstart="window.event.dataTransfer.effectAllowed="move";">
   Highlight text in this paragraph and drag it to the text area bellow
</p>
<textarea id="myTarget" 
          ondrop="transferDrop();" 
          ondragover="window.event.returnValue = false;" 
          ondragenter="transferDrag();">
</textarea>



"dropEffect" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |dataTransfer                                                  |
+----------------+--------------------------------------------------------------+



"dropEffect" Possible Values

Possible Values
copy, 
link, 
move, 
none.



"dropEffect" Syntax and Note

Note:
Read and write property. 
Sets the cursor type for drag and drop operation. 
This property must be accompanied by the effectAllowed property. 
    
Syntax:
    
window.event.dataTransfer.dropEffect = value