I'm trying to get a link that will both open in the current page, or when command/ctrl clicked (etc.) will open in a new tab/window based on the users settings. Right now I'm using something like this:
<a href='http://example.com' onclick="setTimeout(function() {window.location='/some_local_page'}, 10); return false;">Foo!</a> This allows me to click on the link and have it open the local page, but I have to explicitly right click and choose open in new tab/window. I'm pretty sure this is a solved problem, but I can't find the right combination of google/stackoverflow keywords. :)
This might help for clarification:
<a href='http://example.com' onclick="some_javascript_function(); return false;">Foo!</a> In this case a click should call some_javascript_function() and a command/ctrl click should open "http://example.com" in a new tab/window and do nothing to the current page.
setTimeoutto redirect me to a completely different page from the link I clicked on? I'm so confused. Which link do you want to open, and where do you want it to open? Youronclickhasreturn falsewhich stops the browser from following the link normally.