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

3
  • 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. Commented Mar 4, 2019 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 stackoverflow.com/questions/25008877/… Commented Mar 4, 2019 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? Commented Mar 4, 2019 at 15:59

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.