I'm working on a page which works fine for now, but I'd like to make it a bit more responsive by using ajax. So I want to call a JS function and staying on the page when left clicking on a link, but when clicking with the middle mouse button (for opening a new tab) I don't want to execute the function but instead open a new tab (like a regular link).
Right now I have something like this:
<a href="someSite.php" id="myLink">Link</a>
and
myLink.onclick = function () {
doAjax();
return false;
};
But in this case clicking with the middle mouse button calls the function.
Is there a way without using any button detection and no jQuery?