DataTransferItem

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 对象。

This interface has no constructor.

特性

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

方法

DataTransferItem.getAsFile()
返回 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 对象。

范例

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

规范

规范 状态 Comment
HTML Living Standard
The definition of 'DataTransferItem' in that specification.
实时标准 初始定义。
HTML 5.1
The definition of 'DataTransferItem' in that specification.
Recommendation W3C snapshot of WHATWG
文件和目录条目 API
The definition of 'DataTransferItem.webkitGetAsEntry()' in that specification.
草案 Definition of webkitGetAsEntry() as part of the 文件和目录条目 API .

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
DataTransferItem Chrome 11 Edge ≤18 Firefox 50 IE No Opera 12 Safari 5.1 WebView Android 4 Chrome Android 18 Firefox Android 50 Opera Android No Safari iOS 5 Samsung Internet Android 1.0
getAsFile Chrome 11 Edge 12 Firefox 50 IE No Opera 12 Safari 5.1 WebView Android 4 Chrome Android 18 Firefox Android 50 Opera Android No Safari iOS 5 Samsung Internet Android 1.0
getAsString Chrome 11 Edge 12 Firefox 50 IE No Opera 12 Safari 5.1 WebView Android 4 Chrome Android 18 Firefox Android 50 Opera Android No Safari iOS 5 Samsung Internet Android 1.0
kind Chrome 11 Edge 12 Firefox 50 IE No Opera 12 Safari 5.1 WebView Android 4 Chrome Android 18 Firefox Android 50 Opera Android No Safari iOS 5 Samsung Internet Android 1.0
type Chrome 11 Edge 12 Firefox 50 IE No Opera 12 Safari 5.1 WebView Android 4 Chrome Android 18 Firefox Android 50 Opera Android No Safari iOS 5 Samsung Internet Android 1.0
webkitGetAsEntry Chrome 13 Edge 14 Firefox 50 IE No Opera No Safari 11.1 WebView Android No Chrome Android Yes Firefox Android 50 Opera Android No Safari iOS 11.3 Samsung Internet Android Yes

图例

完整支持
完整支持
不支持
不支持