未能在Mozilla Firefox中识别右键单击事件 [英] Failing to identify right click event in Mozilla Firefox

查看:76
本文介绍了未能在Mozilla Firefox中识别右键单击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为右键单击事件添加一些行为。奇怪的是,我根本无法使事件处理工作。

I'm trying to add some behavior for the right click event. Weirdly I simply cannot make the event handling work.

这是jQuery代码:

This is the jQuery code:

$('body').on('click', '#wrapper', null, function(ev){
    if (ev.which === 2 || ev.which === 3){
        alert("Here!");
    }
});

我认为该事件被触发但无法识别为右键。警报消息永远不会显示。
我做错了什么?谢谢!

I think that the event is fired but it cannot be identified as a "rightclick". The alert message is never shown. What am I doing wrong? Thanks you!

LE:我能够用识别左键单击事件ev.which === 1 。所以那里没有问题。

LE: I am able to identify the left click event with ev.which === 1. So there is no problem there.

推荐答案

而不是点击使用 mousedown

$('body').on('mousedown', '#wrapper', null, function(ev){
    if (ev.which === 2 || ev.which === 3){
        alert("Here!");
    }
});​

这篇关于未能在Mozilla Firefox中识别右键单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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