This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

DataTransfer

Summary

Represents an object associated with drag and drop or clipboard events. DataTransfer objects are used to expose the drag data store that underlies a drag-and-drop operation.

Properties

dropEffect
Gets the type of drag-and-drop operation currently selected or sets the operation to a new type.
effectAllowed
Gets which kinds of data transfer operations are allowed for the object. Can be set (during the dragstart event) to change the allowed operations.
files
Returns a FileList of the files being dragged, if any.
items
Returns a DataTransferItemList object containing the drag data.
types
Returns an array listing the formats that were set in the dragstart event. If any files are being dragged, one of the types will be the string "Files".

Methods

clearData
Removes one or more data formats (or all data) from the clipboard through the DataTransfer object or the ClipboardData object.
getData
Gets the data in the specified format from the clipboard through the DataTransfer object or the ClipboardData object. If there is no data, returns an empty string.
setData
Adds data in a specified format to the DataTransfer object or the ClipboardData object.
setDragImage
Uses the given element to update the drag feedback image, replacing any previously specified feedback image.

Events

No events.

Related specifications

HTML5
Candidate Recommendation