What is the way to trap a right-click event on a document element? I could not find any event handlers anywhere.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Right-click is special on many browsers, triggering the
contextmenuevent rather than aclickevent. Some browsers let you prevent the default behavior, some (Opera, for instance) do not. More here: http://unixpapa.com/js/mouse.htmlEDIT: Rereading that page (it’d been a while), it looks like
mousedownandmouseupare even more reliable thancontextmenu(although all major browsers triggercontextmenu).click, on the other hand, doesn’t appear to happen at all, on any significant browser.