This question already has an answer here:
- Is right click a Javascript event? 14 answers
I want to block the standard context menus, and handle the right-click event manually.
How is this done?
This question already has an answer here:
I want to block the standard context menus, and handle the right-click event manually.
How is this done?
Use the
oncontextmenu
event.Here's an example:
And using event listeners:
Don't forget to return false, otherwise the standard context menu will still pop up.
If you are going to use a function you've written rather than
javascript:alert("Success!")
, remember to return false in BOTH the function AND theoncontextmenu
attribute.I think that you are looking for something like this:
(http://www.quirksmode.org/js/events_properties.html)
And then use the onmousedown even with the function rightclick() (if you want to use it globally on whole page you can do this
<body onmousedown=rightclick(); >