DataTransferItem

The DataTransferItem object represents one drag data item. During a drag operation, each drag event has a dataTransfer property which contains a list of drag data items. Each item in the list is a DataTransferItem object.

This interface has no constructor.

Properties

DataTransferItem.kind Read only
The kind of drag data item, string or file.
DataTransferItem.type Read only
The drag data item's type, typically a MIME type.

Methods

DataTransferItem.getAsFile()
Returns the File object associated with the drag data item (or null if the drag item is not a file).
DataTransferItem.getAsString()
Invokes the specified callback with the drag data item string as its argument.
DataTransferItem.webkitGetAsEntry()
Returns an object based on FileSystemEntry representing the selected file's entry in its file system. This will generally be either a FileSystemFileEntry or FileSystemDirectoryEntry object.

Example

All of this interface's methods and properties have their own reference page, and each reference page has an example of its usage.

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'DataTransferItem' in that specification.
Living Standard Initial definition.
HTML 5.1
The definition of 'DataTransferItem' in that specification.
Recommendation W3C snapshot of WHATWG
File and Directory Entries API
The definition of 'DataTransferItem.webkitGetAsEntry()' in that specification.
Draft Definition of webkitGetAsEntry() as part of the File and Directory Entries API.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
DataTransferItemChrome Full support 11Edge Full support ≤18Firefox Full support 50IE No support NoOpera Full support 12Safari Full support 5.1WebView Android Full support 4Chrome Android Full support 18Firefox Android Full support 50Opera Android No support NoSafari iOS Full support 5Samsung Internet Android Full support 1.0
getAsFileChrome Full support 11Edge Full support 12Firefox Full support 50IE No support NoOpera Full support 12Safari Full support 5.1WebView Android Full support 4Chrome Android Full support 18Firefox Android Full support 50Opera Android No support NoSafari iOS Full support 5Samsung Internet Android Full support 1.0
getAsStringChrome Full support 11Edge Full support 12Firefox Full support 50IE No support NoOpera Full support 12Safari Full support 5.1WebView Android Full support 4Chrome Android Full support 18Firefox Android Full support 50Opera Android No support NoSafari iOS Full support 5Samsung Internet Android Full support 1.0
kindChrome Full support 11Edge Full support 12Firefox Full support 50IE No support NoOpera Full support 12Safari Full support 5.1WebView Android Full support 4Chrome Android Full support 18Firefox Android Full support 50Opera Android No support NoSafari iOS Full support 5Samsung Internet Android Full support 1.0
typeChrome Full support 11Edge Full support 12Firefox Full support 50IE No support NoOpera Full support 12Safari Full support 5.1WebView Android Full support 4Chrome Android Full support 18Firefox Android Full support 50Opera Android No support NoSafari iOS Full support 5Samsung Internet Android Full support 1.0
webkitGetAsEntryChrome Full support 13Edge Full support 14Firefox Full support 50IE No support NoOpera No support NoSafari Full support 11.1WebView Android No support NoChrome Android Full support YesFirefox Android Full support 50Opera Android No support NoSafari iOS Full support 11.3Samsung Internet Android Full support Yes

Legend

Full support
Full support
No support
No support