Kayes
Kayes

Reputation: 1086

How to detect file drag on HTML page

I can detect if a file is being dragged on a div by listening to 'dragover' event. But how can I detect if a file is being dragged over the whole HTML page? document.body does not seem to raise the 'dragover' event.

What I intend to do is as soon as a file is dragged over a page, I'll show a hidden div to drop the file on. Just like Gmail.

Upvotes: 2

Views: 1184

Answers (1)

SLaks
SLaks

Reputation: 887453

Make a wrapper <div> with height:100% that contains your entire page and handle its dragover event.

Upvotes: 3

Related Questions