--- title: DragEvent.dataTransfer slug: Web/API/DragEvent/dataTransfer translation_of: Web/API/DragEvent/dataTransfer ---
DataEvent.dataTransfer
属性保存着拖拽操作中的数据(作为一个DataTransfer对象)
This property is {{readonlyInline}}.
var data = dragEvent.dataTransfer;
data
这个例子展示了在{{event("dragend")}} 事件处理程序中获取拖拽中数据的方式。
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 |
---|---|---|
{{SpecName("HTML WHATWG", "interaction.html#dom-dragevent-datatransfer", "DragEvent.dataTransfer")}} | {{Spec2("HTML WHATWG")}} | |
{{SpecName("HTML5.1", "editing.html#dom-dragevent-datatransfer", "DragEvent.dataTransfer")}} | {{Spec2("HTML5.1")}} | Initial definition |
{{CompatibilityTable}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | 4 | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("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 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatNo}} | {{CompatNo}} | {{CompatIE("10")}} | {{CompatNo}} | {{CompatNo}} |