No right-click event Firefox 3.6

Posted by cdmckay on Stack Overflow See other posts from Stack Overflow or by cdmckay
Published on 2010-03-14T22:53:30Z Indexed on 2010/03/14 22:55 UTC
Read the original article Hit count: 354

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?

© Stack Overflow or respective owner

Related posts about firefox

Related posts about JavaScript