Jquery单击事件分配在Firefox中不起作用

Jquery单击事件分配在Firefox中不起作用,jquery,firefox,Jquery,Firefox,我通过类名将一个点击事件分配给一组锚点,它适用于除Firefox之外的所有浏览器,以下是JS: var click_addthis = function(e, href) { if (!e) { var e = window.event; } e.cancelBubble = true; if (e.stopPropagation) e.stopPropagation(); window.open(href, "Share It", null);

我通过类名将一个点击事件分配给一组锚点,它适用于除Firefox之外的所有浏览器,以下是JS:

var click_addthis = function(e, href) {
   if (!e) {
      var e = window.event;
   }
   e.cancelBubble = true;
   if (e.stopPropagation) e.stopPropagation();

   window.open(href, "Share It", null);

   return false;
}

$(document).ready(function() {
   $(".addthis_button_facebook").click(function() { click_addthis(event, this.href) });
   $(".addthis_button_twitter").click(function() { click_addthis(event, this.href) });
});
我错过什么了吗?
谢谢

Firefox的问题在于这一部分:

$(document).ready(function() {
   $(".addthis_button_facebook").click(function() { click_addthis(event, this.href) });
   $(".addthis_button_twitter").click(function() { click_addthis(event, this.href) });
});
您需要从处理程序传入事件,以使其保持一致,如下所示:

$(document).ready(function() {
  $(".addthis_button_facebook").click(function(e) { click_addthis(e, this.href) });
  $(".addthis_button_twitter").click(function(e) { click_addthis(e, this.href) });
});
由于使用相同的函数(
return false
也停止传播),因此也可以将其缩短为:


我的上帝,我爱这个地方,谢谢你!哦,我没有意识到返回错误停止传播!好极了
$(document).ready(function() {
  $(".addthis_button_facebook, .addthis_button_twitter").click(function() { 
    window.open(this.href, "Share It", null);
    return false;
  });
});