Firefox: dragstart event doesn’t fire in hyperlink’s children

走远了吗. 提交于 2019-12-08 02:45:35

问题


There is a problem handling a draggable element which is a child of a hyperlink (a href). Here is HTML:

<a href="#" id="a">Some text
    <span id="span" draggable="true">and some more text</span>
</a>

I try to catch dragstart events for both elements in JS:

var a = document.getElementById('a');
a.addEventListener('dragstart', function() {
  console.log('Dragging a link…');
});

var span = document.getElementById('span');
span.addEventListener('dragstart', function() {
  console.log('Dragging a span…');
});

In Firefox (28.0, Windows 8 and Ubuntu 13.10), if I try to drag the span, only the first handler triggers, but never the second. Other browsers (Chrome, IE) call both handlers successfully. How to make Firefox behave the same way?


回答1:


This is bug 1177704.

Remove href from a for a workaround.



来源:https://stackoverflow.com/questions/23184362/firefox-dragstart-event-doesn-t-fire-in-hyperlink-s-children

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!