JavaScript onDragDrop event

Discuss building things with or for the Mozilla Platform.
Posts: 38
Joined: October 8th, 2004, 1:49 pm

Post Posted October 8th, 2004, 2:26 pm

Neither the onDragDrop element attribute, as used in this demo: ... ondrag.htm

or the ondragdrop window property (window.ondragdrop), as discussed here:

seem to work. They don't produce an error, but the handler never gets called.

This seems to be a capability left out of Mozilla (and in turn Firefox), yet there doesn't appear to be a bug report on it or discussion on the forums, which makes me wonder if it was an intentional omission. One reason why it might be intentional is that to fully handle drag-and-drop you potentially need to set many attributes (enabling the acceptance of dropped items, specifying the types of items accepted, etc.) and handlers, though you can get away with defaults in many cases. I could see developers arguing that merely providing a simple handler would be an incomplete solution, and thus leaving the feature out until someone was ready to implement the full capability. But I haven't seen any discussion like that.

I have found that the DOM specified technique:

document.addEventListener("dragdrop", handler, true);

works in Firefox (and I'd assume Mozilla), but still find it odd that the other documented forms are not functioning.

On a related matter, the DOM method doesn't seem to provide a way to communicate the dropped data. I think attributes of the Event object passed to the handler adequately communicate a reference to the source object when the source is on the same page (or at least the same application), but this doesn't seem to be the case when the source is another application. I've dissected the contents of the Event object passed to the handler, but I can't find any trace of the filename when dragging-and-dropping a file onto the browser window. One old example showed the data being passed as a second parameter to the event handler, but that doesn't seem to be happening now.

I've looked at the XUL equivalent:

in hopes of maybe finding an undocumented property or method that is accessible from JavaScript, but no luck. As best as I can figure, the API mentioned in that document isn't accessible from regular JavaScript and is substantially different from the DOM API.


Posts: 38
Joined: October 8th, 2004, 1:49 pm

Post Posted October 10th, 2004, 11:39 pm

I wrote:
> ...yet there doesn't appear to be a bug report on it...

Correction. I forgot I ran across this:

window.ondragdrop JS event is not getting triggered

in earlier research. Entered in 2001 and no meaningful activity since 2002.

But at least in confirms my observation, even if it doesn't explain why there isn't much interest in fixing it.


old jasonb
Posts: 0
Joined: December 31st, 1969, 5:00 pm

Post Posted October 11th, 2004, 7:19 am

-> Mozilla Development

Return to Mozilla Development

Who is online

Users browsing this forum: No registered users and 0 guests