Right now, I have the following code:
<script>
$("#clickme").click(function(){
$("#clicker").click();
});
</script>
<div id="clickme" style="height:20em; width:20em;">
<a id="clicker" href="http://www.google.com"> Link </a>
</div>
Effectively, if you click anywhere on the background div, the Javascript will simulate a click on the actual link and take you to the destination page.
However, this doesn't work quite so well when you try to ctrl-click, as the browser won't open a new tab, and instead just loads the url into the current window.
Instead of this behavior, I want to have normal browser behavior (i.e. open a new tab, don't change the current window for a ctrl-click) when the background is clicked. Is there a way to do this in Javascript/jQuery?
I'd prefer not to try to detect the "ctrl" key being depressed—there are a few similar cases and I'd rather have a solution that solves everything rather than try to catch every edge case like this.