Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 364
TheBlackBenzKid Avatar asked Nov 11 '12 22:11

TheBlackBenzKid


People also ask

How do you make it so when you click a link it opens a new tab?

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.

How do you get a link to open in a new window or tab use the value for the target attribute?

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).

How can you get a link to be opened in a new tab or browser window?

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.


1 Answers

<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> 
like image 160
John Avatar answered Sep 23 '22 18:09

John