問題描述
我已將事件綁定到不同的元素,當(dāng)我在除 Firefox 之外的所有瀏覽器中拖動它們時,它按預(yù)期工作.然而,在 Firefox 中,它根本不起作用.唯一觸發(fā)的事件是 dragstart
,其他事件都不會觸發(fā).怎么回事?
I have bound events to different elements, and when I drag them in all browsers, except Firefox, it works as expected. In firefox, however, it doesn't work at all. The only event that fires is dragstart
, and none of the other events fire. What's going on?
推薦答案
我沒有使用 jQuery,所以刪除了 originalEvent
部分并將格式更改為文本(或 IE 有問題),并且它有效:
I'm not using jQuery, so removed the originalEvent
portion and changed the format to text (or IE had issues), and it works:
event.dataTransfer.setData('text', 'anything');
在 drop 事件中確保調(diào)用:
In the drop event make sure to call:
event.preventDefault();
或者它會跳轉(zhuǎn)到anything.com.
Or it will jump to anything.com.
這篇關(guān)于為什么 HTML5 拖放功能在 Firefox 中不起作用?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!