如何禁用Firefox的默认拖动并与jQuery的所有图像的行为下降? [英] How to disable Firefox's default drag and drop on all images behavior with jQuery?
本文介绍了如何禁用Firefox的默认拖动并与jQuery的所有图像的行为下降?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Firefox有这种令人讨厌的行为,它让用户拖动,默认情况下删除任何图像元素。我怎样才能干净地使用jQuery禁用此默认行为?
Firefox has this annoying behavior that it let's the user drag and drop any image element by default. How can I cleanly disable this default behavior with jQuery?
推荐答案
下面将做在Firefox 3和更高版本:
The following will do it in Firefox 3 and later:
$(document).on("dragstart", function() {
return false;
});
如果您想preFER不要禁用所有拖动(例如,你不妨仍然允许用户拖动链接到他们的链接工具栏),可以确保只有< IMG>
元素拖动是prevented:
If you would prefer not to disable all drags (e.g. you may wish to still allow users to drag links to their link toolbar), you could make sure only <img>
element drags are prevented:
$(document).on("dragstart", function(e) {
if (e.target.nodeName.toUpperCase() == "IMG") {
return false;
}
});
记住,这将使中的链接图像熊被拖动。
Bear in mind that this will allow images within links to be dragged.
这篇关于如何禁用Firefox的默认拖动并与jQuery的所有图像的行为下降?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文