Home | Top | Free Ajax Editor | JavaScript Editor | Get Advanced JavaScript and Ajax Editor, Validator and Debugger! 1st JavaScript Editor. |
Sets or retrieves, on the source element, which data transfer operations are allowed for the object .
Syntax
dataTransfer . effectAllowed ( v ) [ = sEffect ]Possible Values
sEffect | String that specifies or receives one of the following values.
|
The property is read/write. The property has a default value of uninitialized .
Remarks
Set the effectAllowed property in the ondragstart event. This property is used most effectively with the dropEffect property.
This property can be used to override the default behavior in other applications. For example, the browser script can set the effectAllowed property to copy for a text field and thereby override the Microsoft® Word default of move . Within the browser, copy is the default effectAllowed behavior, except for anchors, which are set to link by default, and text fields, which are set to move by default.
Setting effectAllowed to none disables dropping but still displays the no-drop cursor. To avoid displaying the no-drop cursor, cancel the returnValue of the ondragstart window.
Example
This example uses the dropEffect and effectAllowed properties to move text in a drag-and-drop operation.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Example of the effectAllowed and dropEffect Properties</TITLE> <SCRIPT> // This function is called when the user // initiates a drag-and-drop operation. function fnHandleDragStart() { var oData = window.event.dataTransfer; // Set the effectAllowed on the source object. oData. effectAllowed = "move"; } // This function is called by the target // object in the ondrop event. function fnHandleDrop() { var oTarg = window.event.srcElement; var oData = window.event.dataTransfer; // Cancel default action. fnCancelDefault(); // Set the content of the oTarget to the information stored // in the data transfer object in the desired format. oTarg.innerText += oData.getData("text"); } // This function sets the dropEffect when the user moves the // mouse over the target object. function fnHandleDragEnter() { var oData = window.event.dataTransfer; // Cancel default action. fnCancelDefault(); // Set the dropEffect for the target object. oData.dropEffect = "move"; } function fnCancelDefault() { // Cancel default action. var oEvent = window.event; oEvent.returnValue = false; } </SCRIPT> </HEAD> <BODY> <H1>Example of the effectAllowed and dropEffect Properties</H1> <P>The code in this example sets the <B> effectAllowed </B> property to <SPAN CLASS="literal">move</SPAN>. It sets the <B>dropEffect</B> property to display the move cursor. The default action must be canceled in all events that are handled—in this example, <B>ondragstart</B>, <B>ondragover</B>, <B>ondragenter</B>, and <B>ondrop</B>.</P> <B> [not this text] <SPAN ID="oSource" ondragstart="fnHandleDragStart()"> [select and drag this text] </SPAN> [not this text] </B> <P><BR><P> <DIV ID="oTarget" STYLE="background:beige; height:100; width:200; border:solid black 1px;" ondrop="fnHandleDrop()" ondragover="fnCancelDefault()" ondragenter="fnHandleDragEnter()"> [drop text here] </DIV> </BODY> </HTML>
Standards Information
There is no public standard that applies to this property.
Applies To
|
dataTransfer |
Home | Top | Free Ajax Editor | JavaScript Editor | Get Advanced JavaScript and Ajax Editor, Validator and Debugger! 1st JavaScript Editor. |