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