Usually, when people click on a link, I have onclick bound to it. And then return false.
When people click with “control”, they expect a new page to open up. Therefore, I want to ignore the onclick AND/OR detect it. How do I do this?
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.
The
eventobject has a “ctrlKey” boolean flag, so you can check that in your handler. It depends a little on your framework, but generally if your handler returnsfalsethen you’ll have “defeated” the click.In IE, the
eventobject is a global (that is, a property of the “window” object). In other browsers, it’s a parameter passed to the handler. A common idiom therefore is: