我想在我的 webapp (html5) 中拖放文件时修改浏览器的默认行为。 默认情况下,如果您将文件放在可放置框外,浏览器会尝试打开它并退出当前页面。
在 gmail 上,这是停用的! 您知道这是如何完成的吗?
我在考虑 onbeforeunload 事件,但它会创建一个警报,所以这不是解决方案。
(我正在使用 plupload )
最佳答案
你应该试试这个:
$(window).bind('drop', function(event) {
event.preventDefault();
event.stopPropagation();
});
$(window).bind('dragover', function(event) {// the ondragover event needs to be canceled in Google Chrome and Safari to allow firing the ondrop event:
event.preventDefault();
event.stopPropagation();
});
关于javascript - 文件拖放,检测何时掉到外面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3747666/