jquery – 如何在`drop`事件后停止重定向?

文件放入Firefox中的div后,网页将被重定向到此文件.我试图在drop handler中使用jQuery的e.preventDefault()来阻止这种传播,但是失败了.

请参阅this demo,将文件放入#test不会重定向网页,但是进入#test1会,我想知道原因.我是否应该始终将处理程序绑定到dragenter,dragover,dragleave和drop以防止丢弃后传播?

更新:

我在html5doctor找到了一些提示

To tell the browser we can drop in this element,all we have to do is
cancel the dragover event. However,since IE behaves differently,we
need to do the same thing for the dragenter event.

和Mozilla claims

A listener for the dragenter and dragover events are used to
indicate valid drop targets,that is,places where dragged items may
be dropped.

但是我在firefox上测试this demo,#test的工作和#test1没有,似乎Mozilla犯了一个错误,而html5doctor是对的:Firefox需要dragover才能让drop工作.

解决方法

需要在Google Chrome和Safari中取消ondragover事件才能启动ondrop事件.

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...