1

I am trying to trigger mouse right click and display the events. I tried the following code

document.getElementById("rightclick").addEventListener("click", function({
   $("#phraseDiv").contextmenu();
});

but didn't work. Basically I want to show the browser's rightclick menu on click.

Any help will be much appreciated

Thank you

Binita Gyawali
  • 256
  • 2
  • 13
  • How are you judgingt that it doesn't work? Have you confirmed that your click event handler on `#rightclick` is being called? And have you checked that whatever is supposed to happen when you trigger `contextmenu` is or isn't happening? Do some debugging to check where the code gets to. – Mitya Mar 04 '19 at 11:33
  • 1
    You cannot open context menu of the browser using the left click. JS is not allowed to do so. Here is a similar question https://stackoverflow.com/questions/25008877/how-to-trigger-contextmenu-on-left-mouse-button-click – ellipsis Mar 04 '19 at 11:42
  • Thank you but I am actually trying to trigger the right click on Monaco editor. Is there any way to do that? – Binita Gyawali Mar 04 '19 at 15:59

0 Answers0