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.kindRead only -
The kind of drag data item,
stringorfile. -
DataTransferItem.typeRead only -
The drag data item's type, typically a MIME type.
Methods
DataTransferItem.getAsFile()-
Returns the
Fileobject associated with the drag data item (or null if the drag item is not a file). DataTransferItem.getAsFileSystemHandle()-
Returns a
FileSystemFileHandleif the dragged item is a file, or aFileSystemDirectoryHandleif the dragged item is a directory. DataTransferItem.getAsString()-
Invokes the specified callback with the drag data item string as its argument.
-
DataTransferItem.webkitGetAsEntry() -
Returns an object based on
FileSystemEntryrepresenting the selected file's entry in its file system. This will generally be either aFileSystemFileEntryorFileSystemDirectoryEntryobject.
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 |
|---|
| HTML Standard (HTML) # the-datatransferitem-interface |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
DataTransferItem |
11 |
12 |
50 |
No |
12 |
5.1 |
4 |
18 |
50 |
No |
5 |
1.0 |
getAsFile |
11 |
12 |
50 |
No |
12 |
5.1 |
4 |
18 |
50 |
No |
5 |
1.0 |
getAsFileSystemHandle |
86 |
86 |
No |
No |
72 |
No |
No |
No |
No |
No |
No |
No |
getAsString |
11 |
12 |
50 |
No |
12 |
5.1 |
4 |
18 |
50 |
No |
5 |
1.0 |
kind |
11 |
12 |
50 |
No |
12 |
5.1 |
4 |
18 |
50 |
No |
5 |
1.0 |
type |
11 |
12 |
50 |
No |
12 |
5.1 |
4 |
18 |
50 |
No |
5 |
1.0 |
webkitGetAsEntry |
13 |
14 |
50 |
No |
No |
11.1 |
No |
Yes |
50 |
No |
11.3 |
Yes |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem