views:

227

answers:

1

I'm trying to drag one img and so it fires ondragenter for IE and dragover event for standard browsers, on IE and FF after the user drags it could fire ondrop event however on Webkit based (chrome and safari), i need to cancel or preventDefault() on the dragover event, doing that so will disable the dragging. Any idea on solving this? Thanks

Update: Im referring to designMode='on'

A: 

The HTML5 Spec's default behavior is to automatically cancel then drag action on dragOver/drageEnter unless you cancel (return false and e.preventDefault()) that event yourself. It shouldn't be canceling the drag action at all.

It seems a bit odd at first. But I use this code and it works.

aDivElement.ondrop = function(e) {
  alert("yo");
};

aDivElement.ondragenter = function(e) {
      e.dataTransfer.dropEffect = 'move'
      e.preventDefault();
      return false;
 };

aDivElement.ondragover = function (e) {
   e.dataTransfer.dropEffect = 'move';
   e.preventDefault();
   return false;
 };
Kinlan
Tried this and it does work, the problem if you apply this to designMode='on' where the users can drag anywhere and if i apply e.preventDefault() then the user's drag action is cancelled and the functions on drop would be wrong for i need to do some manipulation based on where the user drop the item. Any Idea on this? Thanks
monmonja