Language References
Provides access to predefined clipboard formats for use in data transfer operations.
The dataTransfer object makes custom handling of editing and drag-and-drop operations possible. It is available through the window object.
The dataTransfer object is used in both source and target events. Typically, the setData method is used in conjunction with source events to provide information about the data being transferred. By contrast, the getData method is used with target events to stipulate what data and data formats to retrieve.
dataTransfer Members
The example shows how to use the setData and getData methods of the dataTransfer object.
Sample Code
<head>
...
<script language="JavaScript">
var sAnchorURL;
function initDrag ( ) {
/* The setData parameters tell the source object
to transfer data as a URL and provide the path. */
window.dataTransfer.setData ( "URL", theSource.href );
}
function endDrag ( ) {
/* The parameter passed to getData tells the target
object what data format to expect. */
sAnchorURL = window.dataTransfer.getData ( "URL" );
theTarget.innerText = sAnchorURL;
}
</script>
...
</head>
<body>
...
<a id="theSource" href="c:\abkd\index.html"
onclick="return ( false )"
ondragstart="initDrag ( )">Test Anchor</a>
<span id="theTarget" ondragenter="endDrag ( )"
style="background:green">Drop the Link Here</span>
...
</body>
Show me
window