2 out of 8 rated this helpful - Rate this topic

dataTransfer object

[This documentation is preliminary and is subject to change.]

Provides access to predefined clipboard formats for use in drag-and-drop operations.

Standards information

There are no standards that apply here.

Remarks

The dataTransfer object makes it possible to customize the handling of drag-and-drop operations. It is available through the event object.

The dataTransfer object is used in source and target events. Typically, the setData method is used with source events to provide information about the data being transferred. In contrast, the getData method is used with target events to stipulate which data and data formats to retrieve.

This object is available in script as of Microsoft Internet Explorer 5.

Examples

This example uses the setData and getData methods of the dataTransfer object to perform a drag-and-drop operation.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/obj_dataTransferEX.htm


<head>
<script>
var sAnchorURL;
function InitiateDrag() 
/*  The setData parameters tell the source object
    to transfer data as a URL and provide the path.  */
{   
    event.dataTransfer.setData("URL", oSource.href);
}
function FinishDrag()
/*  The parameter passed to getData tells the target
    object what data format to expect.  */
{
    sAnchorURL = event.dataTransfer.getData("URL")
    oTarget.innerText = sAnchorURL;
}
</script>
</head>
<body>
<a id="oSource" href="about:Example_Complete" onclick="return(false)"
    ondragstart="InitiateDrag()">Test Anchor</a> 
<span id="oTarget" ondragenter="FinishDrag()">Drop the Link Here</span>
</body>

 

 

Build date: 3/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Caution - unknown readystate

There's no apparent documentation on the dataTransfer readyState:--

Tell your Web-Users to "WATCH FOR LATE COPY-DATA IF THE DATATRANSFER IS BIG...".

But, There's no apparent documentation for a dataTransfer onready event...