4

I'm in the process of porting an app to JavaScript/CSS and it uses right-click. For some reason Firefox 3.6 for Windows isn't issuing a right-click event, but Chrome and IE do. Here's some test code. If you right-click #test then you get nothing in Firefox but you get an alert under Chrome and IE.

<html>
    <head>
        <title>Hi</title>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript">
        $(function(){
            $("#test").get(0).oncontextmenu = function() { return false; };
            $("#test").mousedown(function() { alert("hi"); });
        });
        </script>
    </head> 
    <body>
        <div id="test" style="background: red;">Hi</div>
    </body>
</html>

Why isn't the right-click event being generated in Firefox?

cdmckay
  • 31,832
  • 25
  • 83
  • 114

5 Answers5

3

I found the problem. I have the "All-in-One Gestures" extension installed. I tried running the code with it disabled and it worked fine. Looks like a bug/limitation of the extension.

Update: I just tried the "Mouse Gestures Redox" extension and it does not have this problem.

cdmckay
  • 31,832
  • 25
  • 83
  • 114
2

Firefox 3.6 gives the alert just fine on either left or right click on my Mac (OSX 10.5) as do Safari and Google Chrome. No idea why your Windows version doesn't -- doesn't sound like a programming problem of yours, more like a Firefox/Windows bug maybe...?

Alex Martelli
  • 854,459
  • 170
  • 1,222
  • 1,395
2

There is an option in Firefox: Content => Javascript => Advanced => Allow Disable/Replace Context Menus.

Andras Vass
  • 11,478
  • 1
  • 37
  • 49
  • It might be that in some builds even though the checkbox is shown as checked, internally the flag is not set by default. If this is the case, check out the post by Bob McCapherey: http://support.mozilla.com/tiki-view_forum_thread.php?locale=es&forumId=1&comments_threshold=0&comments_parentId=385168&comments_offset=20&comments_per_page=20&thread_style=commentStyle_plain – Andras Vass Mar 14 '10 at 23:16
  • You can check if this is the case by going to about:config and looking for `dom.event.contextmenu.enabled` . – Andras Vass Mar 14 '10 at 23:21
  • 1
    `dom.event.contextmenu.enabled` is set to true. The option in the Firefox menu is also checked. Still no go on the right-click. – cdmckay Mar 14 '10 at 23:46
  • @cdmckay: I'm glad that you've found it finally. ;-) (Sorry, I went offline shortly after posting.) Subjective conclusion: after checking that everything should work, disable plugins/add-ons one-by-one. Most of the time, they are responsible for the mess... Why don't you mark your answer then? – Andras Vass Mar 15 '10 at 22:54
  • @andras: I think that's a sensible conclusion. I can't accept my own answer until 48 hours pass :( – cdmckay Mar 16 '10 at 04:47
1

I tested your code. Firefox 3.6 gives the alert on my XP (SP3) machine.

Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
0

Just to add to the list. I had Multi Links add-ons installed that was preventing the right click.

Bastan
  • 1,009
  • 1
  • 8
  • 10