Ctrl or Shift on the `onclick` event of the anchor tag in each browser

I recently discovered that different browsers handle the onclick event differently when the Control or Shift keys are pressed. They are equally different from the behavior for the following links by clicking the middle mouse button.

With the following link:

 <a href="http://www.example.com/" onclick="alert('onclick');">go to example.com</a> 

Onclick Browser Support Chart

 Mouse Keyboard Chrome Firefox Safari Opera IE5.5 IE6 IE7 IE8 IE9 Left None yes yes yes yes yes yes yes yes yes Left Ctrl yes yes yes yes ? yes no no ? Left Shift yes yes yes yes ? yes yes yes ? Middle None yes no yes no ? N/A no no ? 

Can anyone fill out question marks for me? Also; I am wondering if the behavior is different from each version of Chrome, Firefox, Safari and Opera.

Finding a logical pattern in this behavior will be even nicer, but I don’t think there is, unfortunately. :)

+6
javascript events onclick ctrl shift
source share
1 answer

See my answer to the corresponding question.

This is due to the "expected behavior" when the user uses the keyboard buttons with a modifier click - the user expects Ctrl + Click on the link to open this link in a new tab or window. Microsoft executives decided that the only reason the user could Ctrl + click was because they expected this behavior, so these clicks do not trigger the onclick event in Internet Explorer.

+2
source share

All Articles