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

前端 未结 5 1241
感动是毒
感动是毒 2021-02-01 02:36

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 eve

5条回答
  •  盖世英雄少女心
    2021-02-01 03:08

    I'm not using jQuery, so removed the originalEvent portion and changed the format to text (or IE had issue), 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.

提交回复
热议问题