Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I open a link in new tab (and not new window)? [duplicate]

I have an 'Open' button that 'calculates' a link that should be opened in a new tab. I try to use:

window.open(url, '_blank'); 

But that opens a new window.

I also tried the following method:

<form id="oform" name="oform" action="" method="post" target="_blank"> </form>  ...  document.getElementById("oform").action = url; document.getElementById("oform").submit(); 

Still, a new window is opened, instead of a new tab.

When using simple <a href...> with target='blank', the link is opened in a new tab.

Is there a solution?

like image 820
Erik Sapir Avatar asked Jun 09 '11 16:06

Erik Sapir


People also ask

How do I make a link open in new tab instead of new window?

To open a link in a new browser window, hold the Shift on then click the link or right-click the link and select Open link in New Window.

How can you open a link in its own unique new window?

You just need an anchor ( <a> ) element with three important attributes: The href attribute set to the URL of the page you want to link to. The target attribute set to _blank , which tells the browser to open the link in a new tab/window, depending on the browser's settings.

Why is every link opening in a new window?

Make sure you do not have sticky keys on, that may cause a problem. Shift-clicking a link in Chrome opens a new window. Press shift more than five times rapidly to find out if sticky keys are on. Another clue is if your text is always capitalized and numbers come out as symbols.

How do I make a clickable link open in a new tab?

You can make a HTML link open in a new tab by adding the target=”_blank” attribute. You should insert this after the link address.


1 Answers

Update [2019] Most browsers today open in a new tab when you set the target to _blank. The days of popup windows is long gone. We can now use:

 <a href="some url" target="_blank">content of the anchor</a> 

Most sane browsers will open the new window in a new tab.


CSS3 supports "open in new tab", by the property target-new

target-new: window | tab | none; 

Update [2016]: this method never made it into the CSS3 spec, as one of the comments indicates. This shouldn't be used. However, it can be seen that most modern browsers open target='_blank' links in a new tab anyway, unless one attempts to resize the new tab immediately thereafter. However, there does not appear to be a mechanism to force this behavior in the specifications.


[2011] For a method of forcing opening in a new tab that is well supported, try the following:

<a href="some url" target="_newtab">content of the anchor</a> 

Else, use this method to resize window immediately, to ensure that popup blockers do not kill your popup

like image 165
Anirudh Ramanathan Avatar answered Sep 21 '22 09:09

Anirudh Ramanathan