HTML5 drop event doesn't work unless dragover is handled

后端 未结 4 1077
一生所求
一生所求 2020-12-02 16:51

I am listening to the drop event and doing e.preventDefault() But its trying to open the dropped file. It was working fine till yesterday. But just

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 17:32

    I'm not sure if I understand your problem correctly but if you want to read dropped files you need to handle dragover event and put there at least this line of code:

    evt.dataTransfer.dropEffect = 'copy';
    

    otherwise dropEffect is null by default and you won't get any data.

提交回复
热议问题