There is no built-in oncontextmenu event handler in jQuery, but you can do something like this:
$(document).ready(function(){ document.oncontextmenu = function() {return false;}; $(document).mousedown(function(e){ if( e.button == 2 ) { alert('Right mouse button!'); return false; } return true; }); });
Basically, I cancel the oncontextmenu event of the DOM element to disable the browser context menu, and then I capture the mousedown event using jQuery, and there you can find out in the event argument which button was pressed.
You can try the above example here .
CMS Apr 01 '09 at 18:07 2009-04-01 18:07
source share