Hai group,


im a newbie in HTML,CSS,JAVASCRIPT..
I was involved in dev of a prototype using the above 3...
everything went fine...but the pending requirement is ..
when we right click on a row in table in a prototype, we have coded such that a context menu appears..its working fine..but if we click on empty space in the html prototype, we r getting the default context menu which we dont want...

could any one of u can help me plzzzzzzz

I think you'll have to code to the Event object, which has cross-browser issues. But the Event object is created when any event occurs, and you might be able to tell if a click was a left or a right click and code accordingly. So my first thought would be to research the JavaScript "Event" object.

Wait... I know IE provides an "oncontextmenu" event handler. I'm not sure about FireFox.

You could code that in the body, as so:

<body oncontextmenu="return false;">

However, this is where I make my standard plea/warning: users expect that when they right-click, they get a context menu. I, for example, routinely use it to access "back". It's faster than mousing up to the top of the browser. Disabling or co-opting features that users have come to expect violates a basic application design principle, and should be avoided, in my opinion.

So unless you have a very compelling reason for doing this, I would suggest that you leave it alone.

Wait... I know IE provides an "oncontextmenu" event handler. I'm not sure about FireFox.

You could code that in the body, as so:

<body oncontextmenu="return false;">

However, this is where I make my standard plea/warning: users expect that when they right-click, they get a context menu. I, for example, routinely use it to access "back". It's faster than mousing up to the top of the browser. Disabling or co-opting features that users have come to expect violates a basic application design principle, and should be avoided, in my opinion.

So unless you have a very compelling reason for doing this, I would suggest that you leave it alone.

Thanks a lot...that worked fine...

We're venturing off into another discussion. I don't know the particulars of the OP's environment or application, but in general, I say "hands off" on anything that is in the User Model. This includes such often-requested items as auto-sizing a window, auto-printing a page, disabling certain script warnings, obscuring or making "View Source" difficult, and replacing or editing the context menu.

This link should be of interest to you in regard to adding to context menu(s):

http://msdn.microsoft.com/workshop/browser/ext/tutorials/context.asp

That's something you have to do internally to your windows machine though (which rocks for me, but not for someone trying to do it through a web page... now if we can find out where that same type of key is for firefox).

If I'm not mistaken, you could use a DIV with some crazy CSS (to hide and show the div) with an absolute positioning, set the oncontextmenu to a function (which shows the div, and returns false for the actual context menu), but the context menu has things that you can't make happen within a page.

but I seriously agree with tgreer, screwing with people's interface is a bad idea.... 9 times out of 10, if a page is messing with things I don't think it should be, I'm gone. I won't stay there. I don't even like pages playing music, or embedding objects (like media player) when I first navigate there. Now, I've done this before (made a page which replaces the context menu), but I made it a choice in preferences, and I made it disabled by default (meaning, in order to use my div menu, they had to consciously go in and turn it on), and beyond that, I made an option in the DIV for "Standard Menu" so when they clicked that, it would load the normal context menu the next time they clicked.

If you feel absolutely drawn to having to affect the users interface, words of wisdom say to make sure that the user can get back to a familar environment with no effort.

This question has already been answered. Start a new discussion instead.