Answers for "how to add function on right click"

0

how to add function on right click

if (document.addEventListener) {
  document.addEventListener('contextmenu', function(e) {
    alert("You've tried to open context menu"); //here you draw your own menu
    e.preventDefault();
  }, false);
} else {
  document.attachEvent('oncontextmenu', function() {
    alert("You've tried to open context menu");
    window.event.returnValue = false;
  });
}
Posted by: Guest on July-14-2021

Code answers related to "how to add function on right click"

Browse Popular Code Answers by Language