Brett
Brett

Reputation: 332

html5 drag/drop determine source of dragged item

If I drag a file onto a webpage it fires the dragenter event. If I drag an element it also fires the same event. How might I determine if the dragged item is coming from html or from an external app like explorer.

Thanks.

Upvotes: 2

Views: 2164

Answers (1)

Joe M
Joe M

Reputation: 2657

If you are doing the drag and drop from html, you would do

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

and

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

If you are getting items from explorer, you would do

var files = e.dataTransfer.files;

So I think you would know, where it is coming from.

Upvotes: 3

Related Questions