Search code examples
javascriptfirefoxdrag-and-drop

Why doesn't HTML5 drag and drop work in Firefox?


I have bound events to different elements, and when I drag them in all browsers, except Firefox, it works as expected. In firefox, however, it doesn't work at all. The only event that fires is dragstart, and none of the other events fire. What's going on?


Solution

  • I'm not using jQuery, so removed the originalEvent portion and changed the format to text (or IE had issues), and it works:

    event.dataTransfer.setData('text', 'anything');  
    

    In the drop event make sure to call:

    event.preventDefault();
    

    Or it will jump to anything.com.