I'm developing for a site that does something a bit strange with some links.
When the user clicks on a link, an indicator GIF that looks kinda like this appears next to the link, and the link itself is disabled. It then navigates to the page. This is because of concerns that impatient users might repeatedly click the link if it doesn't load immediately, putting an extra load on our server.
Here's how we do this:
<a id="link1" href="/target_page"
onclick="var link = document.getElementById('link1');
var loc = link.href;
link.removeAttribute('href');
link.setAttribute('onclick', 'return false;');
document.getElementById('link1_img').style.display='';
window.location = loc;">
Link Text
<img id="link1_img" src="/images/indicator.gif" style="display:none;" />
</a>
Here's the problem. While this has the expected behavior if the user clicks on the link normally, or right-clicks it and opens it in a new window or tab from the context menu, it doesn't always work properly if the user middle-clicks or Ctrl+clicks on the link.
The desired behavior in that case would be to skip all the JavaScript stuff and simply open the link in a new tab. I did a quick test on Windows with the latest version of each major browser, and IE, Firefox, and Opera all do this. Chrome and Safari, however, display the indicator and open the link in the current tab.
Any suggestions on how to make it behave consistently on all browsers?