How can I make a HTML a href hyperlink open a new window?

TheBlackBenzKid picture TheBlackBenzKid · Nov 11, 2012 · Viewed 222.9k times · Source

This is my code:

<a href="http://www.google.com" onClick="window.location.href='http://www.yahoo.com';return false;" target="_blank">test</a>

When you click it, it takes you to Yahoo but it does not open a new window?

Answer

John picture John · Nov 11, 2012
<a href="#" onClick="window.open('http://www.yahoo.com', '_blank')">test</a>

Easy as that.

Or without JS

<a href="http://yahoo.com" target="_blank">test</a>