Firefox: dragstart event doesn’t fire in hyperlink

2019-05-20 03:36发布

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条回答
smile是对你的礼貌
2楼-- · 2019-05-20 04:31

This is bug 1177704.

Remove href from a for a workaround.

查看更多
登录 后发表回答