I often command-click links in order to open them in a new tab. I find it very irritating when a site’s JS usurps that functionality.
It turns out that click events have a boolean attribute – event.metaKey
– that is true
on command-click. So, you can event.preventDefault()
your heart out and still easily retain the expected command-click behaviour.
$(".something").click(function(event){
if (!event.metaKey) {
event.preventDefault();
// etc
} else {
//other stuff
}
})