Reputation: 3552
Here's an example of drag&drop images (provided from course "HTML5 power workshop" by Andy Olsen) : http://aorbaroquethrash.com/dragdrop/
You have to drag an image from your desktop to the yellow square.
It is working in chrome, but not firefox, why ?
There's a similar post : drag and drop not working in firefox It says to use "dataTransfer.setData", but I don't think it applies to my example.
In my example I use
var allTheFiles = event.dataTransfer.files;
...
PatricK
Upvotes: 0
Views: 3897
Reputation: 33162
That site has a bug. The code reads:
// Handles drop events.
function onDrop(mouseEvent) {
...
// Get the first file dragged by the user.
var allTheFiles = event.dataTransfer.files;
var firstFile = allTheFiles[0];
…
}
event.dataTransfer.files
should be mouseEvent.dataTransfer.files
.
The reason it works in Chrome is apparently that Chrome implement non-standard, IE-style window.event
, while Firefox does not.
Here is a corrected fiddle that works (tested) in Firefox, Chrome, Safari and even IE10.
Upvotes: 1