1
的Jquery:防止默认操作。只有在工作铬
$(document).ready(function() {
$('input[type=file]').uploadImage();
jQuery.event.props.push('dataTransfer');
$(".upload-cont").bind('dragenter', function (e) {
$(".upload-cont").css("border", "1px dashed black;");
});
$(".upload-cont").bind('drop', function (e) {
var files = e.dataTransfer.files;
e.preventDefault();
});
$("body").bind('drop', function (e) {
e.preventDefault();
});
});
在Firefox 17浏览器中拖拽并从桌面拖放文件到浏览器中的图像将在另一个页面加载时8。我添加了可以在Chrome中完美工作的preventDefault()。可以做什么以便在ff即浏览器中阻止该操作。
很高兴帮助。我最近有一个类似的问题。 –
这将是一个更好的答案,如果它包含关于为什么OP的代码被破坏以及为什么这会修复它的解释。 – Sparky
@Sparky你是对的,我把它添加到答案中。我花了一分钟才找到源代码。 :) –