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?
You can also click on a link and hold down the mouse without releasing, dragging the link to the browser's tab bar to open it in a new tab. If you prefer, you can also right-click on a link in Chrome or many other browsers to open a menu that allows a variety of options.
A target attribute with the value of “_blank” opens the linked document in a new window or tab. A target attribute with the value of “_self” opens the linked document in the same frame as it was clicked (this is the default and usually does not need to be specified).
Using _blank will tell the browser to use a new tab/window, depending on the user's browser configuration and how they click on the link (e.g. middle click, Ctrl +click, or normal click). Additionally, some browsers don't have a tabs feature and therefore cannot open a link in a new tab, only in a new window.
<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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With