Rudie
Rudie

Reputation: 53781

(drag n) drop files in Firefox

Because a demo is worth 72.814 words: http://jsfiddle.net/rudiedirkx/J575b/3/show/

That's the simplest demo. Three events: drag over, drag leave and drop. over and leave work as expected (the class is added and removed). The drop however doesn't!

Like IE, it opens the dropped file in the window. In Chrome the event cancels and the dragging file is dropped (and ignored in this case).

The drop event doesn't even trigger in Firefox!?

What's going on? I thought this worked... (It does in Chrome. It doesn't in Opera 11.64.)

EDIT

Fixed, thanks to Adriano: http://jsfiddle.net/rudiedirkx/J575b/5/show/

Upvotes: 1

Views: 1594

Answers (1)

Adriano Repetti
Adriano Repetti

Reputation: 67070

Change your ondragover handler to this:

drop.ondragover = function() {
    this.classList.add('over');
    return false;
};

Note the return false line, from Mozilla.org you need to preventDefault() or return a false value from the function to allow the drop.

Upvotes: 2

Related Questions