I’m trying to make a right click menu on a particular type of DIV … thought i had it working because when I debug in Visual Studio, the right click menu does not appear. But when I run it without debugging, the right menu does appear!
If I use an alert() function, this kills the right menu but I do not want to use an alert, I simply want an alternate right click menu to appear and just cant seem to keep the default menu from appearing.
Here is a fiddle: http://jsfiddle.net/tvance929/5N2ak/
You will notice that if you comment out the alert line – the right click menu will reappear.
I have tried both RETURN FALSE and e.preventdefault() … Im missing something.
Your answer seems to solve the problem only in IE8. In IE5-9 the fix is to use
oncontextmenuinstead ofonkeydownand in handler: