Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Ajax Programming

Sort of an AJAX question

This question is more of a Javascript question, but I figure fellow
AJAX users have probably come across this long before I have. I'm
trying to create a small context popup on the page when the user right
clicks the page. The context menu is a simple table hidden on the
screen that is moved to the user's cursor and displayed. My audience
is 100% I.E. so cross-browser compatibility isn't as important as it
would be on an externtal web page.

The problem I'm having is I cannot stop the default right-click action
in IE which displays the full IE context menu. The following code
cancels the event *only* if I put an alert() in it at some point, even
with the cancelBubble() and returnValue() functions.

<script language="javascript">
    function CheckButton(evt)
        var button = event.button;
        switch (button)
            case 2:
                evt.cancelBubble = true;
                evt.returnValue = false
            case 1:
                alert("Button 1!");
        event.cancelBubble = true;
        event.returnValue = false
        return false;

<tr onclick="CheckButton()">

Have you run across this before and is there a fix for it?


Oops, the table event should be:

<tr onmouseup="CheckButton()">


You need to return false with the oncontextmenu

On 2/28/07, RisingFish <risingf@gmail.com> wrote:

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc