0

I want a link that submits some POST data. This works:

<a href="#" onclick="document.forms[0].foo = 42; document.forms[0].submit(); return false">Bar</a>

However, if I middle-click (Google Chrome: open link in new tab) on links that are formed like that, the page doesn't open in a new tab; rather, the link gets followed in the current tab. This isn't nice and it's unexpected behavior to boot (one expects middle-clicking would work on this link just like on any other).

How do I make this link act more like an actual link, particularly, by making this middle-click behavior work as usual?

Claudiu
  • 224,032
  • 165
  • 485
  • 680

1 Answers1

0

You'll probably have to handle that logic in the onclick event manually, by detecting what button is pressed and then behaving accordingly.

Christopher Armstrong
  • 7,907
  • 2
  • 26
  • 28
  • i'm looking for a general answer, like, how do I make the link behave exactly like how the browser would make an ordinary link behave? also: can you be more specific as to how i would do what you suggest? – Claudiu Jul 09 '12 at 19:56
  • http://stackoverflow.com/questions/3272715/problem-with-onclick-and-middle-button-on-mouse – orangegoat Jul 09 '12 at 19:59