Firefox:dragstart事件在超级链接的子级中不会触发 [英] Firefox: dragstart event doesn’t fire in hyperlink’s children

查看:252
本文介绍了Firefox:dragstart事件在超级链接的子级中不会触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

处理超链接( a href )的可拖动元素有问题。这是HTML:

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>

我尝试捕获两个事件的 dragstart 事件JS中的元素:

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…');
});

在Firefox(28.0,Windows 8和Ubuntu 13.10)中,如果我尝试拖动跨度,第一个处理程序触发,但从不第二个。其他浏览器(Chrome,IE)都会成功调用处理程序。如何使Firefox的行为方式相同?

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?

推荐答案

这是 bug 1177704

删除 href a 为解决方法。

这篇关于Firefox:dragstart事件在超级链接的子级中不会触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆