For a right click you need to use the preventDefault method.
In jQuery you can do it like:
$(document).on("mousedown", "a", function(e) { if( e.which === 3 ) { e.preventDefault();
Use 1 for left click, 2 for middle click and 3 for right click.
In JavaScript:
<a href="#" onmousedown="mouseDown(event);">aaa</a>βββββββββββββββββββββββββββ function mouseDown(e) { e = e || window.event; switch (e.which) { case 1: alert('left'); break; case 2: alert('middle'); break; case 3: alert('right'); break; } }β
Demo
source share