JavaScript onDragDrop event

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

JavaScript onDragDrop event

Post by tmetro »

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

http://developer.netscape.com/docs/tech ... ondrag.htm

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

http://www.faqts.com/knowledge_base/view.phtml/aid/2118

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:
http://xulplanet.com/tutorials/xultu/dragdrop.html

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.

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

Re: JavaScript onDragDrop event

Post by tmetro »

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
https://bugzilla.mozilla.org/show_bug.cgi?id=112288

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.

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

Post by old jasonb »

-> Mozilla Development
Post Reply