How can I make href HTML link open in a new window using window.location?

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 on it, it will lead you to Yahoo, but it will not open a new window?

+52
html window.location hyperlink
Nov 11
source share
1 answer
 <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> 
+96
Nov 11 '12 at 22:12
source share



All Articles