Prevent browser from loading a drag-and-dropped file

前端 未结 10 2019
逝去的感伤
逝去的感伤 2020-11-28 02:12

I\'m adding an html5 drag and drop uploader to my page.

When a file is dropped into the upload area, everything works great.

However, if I accidentally drop

10条回答
  •  旧巷少年郎
    2020-11-28 02:28

    For jQuery the correct answer will be:

    $(document).on({
        dragover: function() {
            return false;
        },
        drop: function() {
            return false;
        }
    });
    

    Here return false will behave as event.preventDefault() and event.stopPropagation().

提交回复
热议问题