You need to use the ondrop event, which will fire only if the ondragenter and ondragover events are canceled. It turns out this is a little more complicated because the behavior in Firefox is different from IE, Safari and Chrome.
(function () { var inp = document.getElementById("test"), chg = false; inp.ondragover = inp.ondragenter = function () { chg = inp.value == "Drop here"; return false; } inp.ondrop = function (evt) { evt = evt || event; if (chg) { this.value = evt.dataTransfer.getData("text") || evt.dataTransfer.getData("text/plain"); return false; } } })();
An example is Firefox 3+, IE5 +, Chrome, and Safari. Nearby, as far as I can tell, Opera does not support this event. At least you can make it work for 95% of your visitors.
Drag and Drop Operations - MDC
Andy e
source share