DragEvent.dataTransfer
DataEvent.dataTransfer
屬性保留了拖曳操作中的資料(指向一個 DataTransfer
物件)。
此屬性為 Read only 。
語法
var data = dragEvent.dataTransfer;
回傳值
data
- 一個保存
DragEvent
當中資料的DataTransfer
物件。
範例
This example illustrates accessing the drag and drop data within the dragend
event handler.
function process_data(d) {
// Process the data ...
}
dragTarget.addEventListener("dragend", function(ev) {
// Call the drag and drop data processor
if (ev.dataTransfer != null) process_data(ev.dataTransfer);
}, false);
規範
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'DragEvent.dataTransfer' in that specification. |
Living Standard | |
HTML 5.1 The definition of 'DragEvent.dataTransfer' in that specification. |
Recommendation | Initial definition |
瀏覽器相容性
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 4 | (Yes) | 3.5 (1.9.1) | 10 | 12 | 3.1 |
Feature | Android | Android Webview | Chrome for Android | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|---|---|
Basic support | No support | No support | No support | (Yes) | No support | No support | 10 | No support | No support |