This used to be my (working) code:
<div onclick="location.href='http://somewebsite.com/';">
<a href="http://someotherwebsite.com/">Link</a>
</div>
If I'd click the link, I would be taken to http://someotherwebsite.com/. If I'd click somewhere else in the div
, I would be taken to http://somewebsite.com/. Perfect.
Then, I decided that I wanted to open http://someotherwebsite.com/ in a new tab upon clicking the link, so I changed my code to this:
<div onclick="location.href='http://somewebsite.com/';">
<a href="http://someotherwebsite.com/" target="_blank">Link</a>
</div>
However, if I'd click the link now, I would be taken to http://somewebsite.com/ instead of http://someotherwebsite.com/! Apparently, adding target="_blank"
to my anchor tag caused my onclick
method to override my anchor tag's href
. What's going on?
Edit: It turns out, my code does function properly in Chrome, but not in Safari 7.0.5. What can I do to add Safari support?