I Believe in the Middle Click
horia.me
horia.me
It’s annoying, but not inexplicable.
In the former case, you have event.button = 0, and event.ctrlKey = true. In the second case, you have event.button = 2, and event.ctrlKey = false.
What happens depends on the logic inside the handler.
On the other hand, if you attach a handler to the click event, it doesn't seem to fire for either right click or ⌃-click.
This is what I use:
$('.some-snazzy-selector').click(function(ev){
if( ev.which == 2 || ev.metaKey || ev.ctrlKey || ev.shiftKey ) return true;
e.preventDefault();
/* Awesome AJAX code goes here */
});
I posted this comment on the blog, but it may reach someone else here, too.Started using this when the middle-click on my mouse broke from too much use.
But, generally speaking, developers don't really take this into account.
I do that too, for what I visit regularly and presents said problem... but it can sometimes hit unexpectedly.