JavaScript Reference/Javascript Properties/effectAllowed

Материал из Web эксперт
Версия от 08:21, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"effectAllowed" 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>



"effectAllowed" is applied to

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



"effectAllowed" Possible Values

Possible Values
copy           allows the copy operation, 
link           allows the selection to be linked with the drop target
move           allows the selection to be moved to the drop target
copyLink       allows the copy or link operation, 
               depending on the target settings, 
copyMove       allows the copy or move operation, 
               depending on the target settings, 
linkMove       allows the link or move operation, 
               depending on the target settings, 
all            allows all drop effects), 
none           no drop effect is allowed and 
               the no-drop cursor is shown
uninitialized  the default; the effectAllowed property 
               has not been initialized yet



"effectAllowed" Syntax and Note

Note:
Read and write property. 
Sets the data transfer operation. 
This property must be accompanied by the dropEffect property. 
    
Syntax:
    
window.event.dataTransfer.effectAllowed = value