This constructor is used to create a synthetic DragEvent 对象。

Although this interface has a constructor, it is not possible to create a useful DataTransfer object from script, since DataTransfer objects have a processing and security model that is coordinated by the browser during drag-and-drops.

此接口继承特性从 MouseEvent and 事件 .

句法

 event = new DragEvent(type, DragEventInit);
					

自变量

type
DOMString representing the name of the event (see DragEvent event types ).
DragEventInit 可选
DragEventInit 字典,拥有以下字段:
  • "dataTransfer" , optional and defaults to "null" . The type is DataTransfer .

DragEventInit dictionary inherits from the MouseEventInit dictionary .

规范

规范 状态 注释
HTML 实时标准
The definition of 'DragEvent' in that specification.
实时标准
HTML 5.1
The definition of 'DragEvent' in that specification.
推荐 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
DragEvent() 构造函数 Chrome 46 Edge 12 Firefox 3.5 IE 10 Opera 12 Safari 3.1 WebView Android No Chrome Android No Firefox Android Yes Opera Android No Safari iOS No Samsung Internet Android No

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改:
  1. HTML 拖放 API
  2. DragEvent
  3. 构造函数
    1. DragEvent()
  4. 特性
    1. dataTransfer
  5. 继承:
    1. MouseEvent
    2. UIEvent
    3. 事件
  6. Related pages for HTML Drag and Drop API
    1. DataTransfer
    2. DataTransferItem
    3. DataTransferItemList