1element.addEventListener('contextmenu', (e) => {
2 e.preventDefault();
3 alert('Success');
4}, false);
1 function rightclick() {
2 var rightclick;
3 var e = window.event;
4 if (e.which) rightclick = (e.which == 3);
5 else if (e.button) rightclick = (e.button == 2);
6 alert(rightclick); // true or false, you can trap right click here by if comparison
7}
8