问题描述
我正在监听 drop
事件并执行 e.preventDefault()
但它试图打开删除的文件.直到昨天它工作正常.但就在今天,它不知什么原因坏了.我做了一个 JsFiddle#bwquR/10
来反映相同的.
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 today It broke for some unknown reason. I made a JsFiddle#bwquR/10
to reflect the Same.
看起来如果你不采取 dragover
事件 drop
是无法处理的.即使在小提琴中如果您评论 dragover
它将无法正常工作.
在实际工作中我错过了 dragover
的拼写但它仍然是一个问题 drop
will not work without dragover
It looks like if you don't take the dragover
event drop
cannot be handled. even in the the fiddle If you comment the dragover
It will not work.
In the actual work I missed the spelling of dragover
But its still a question drop
will not work without dragover
小提琴实际上在工作,但身体太小了(只有文本 DROP
那里).它仅在 DROP
文本不在整个正文上的那个小区域上发生 drop
事件.所以我认为它不起作用.很抱歉造成混乱.
The fiddle was actually working but s the body was so small (only text DROP
there). It was taking drop
event only on that small area where DROP
text lies not on the entire body. So I thought It was not working. Sorry for the confusion.
推荐答案
我猜是因为没有dragOver事件处理程序,使用了dragOver事件的默认事件处理程序,因此之后没有触发drop事件.在放置事件之前需要 e.preventDefault
用于 dragOver 事件.
I guess it is because that without dragOver event handler, default event handler of dragOver event is used, thus, no drop event is triggered after that. There is a need with e.preventDefault
for dragOver event before drop event.
这篇关于除非处理了拖动,否则 HTML5 放置事件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!