html5拖放确定拖动项目的来源

html5 drag/drop determine source of dragged item

本文关键字:项目 拖动 拖放 html5      更新时间:2023-09-26

如果我将文件拖到网页上,它会触发draginter事件。如果我拖动一个元素,它也会引发相同的事件。我如何确定拖动的项目是来自html还是来自像explorer这样的外部应用程序。

谢谢。

如果你从html进行拖放,你会进行

e.dataTransfer.setData() //at the source

e.dataTransfer.getData() //at the destination

如果你从资源管理器中获取项目,你会进行

var files = e.dataTransfer.files;

所以我想你会知道,它是从哪里来的。