我如何在新标签页中打开链接(而不是新窗口)? [英] How can I open a link in new tab (and not new window)?
问题描述
我有一个打开按钮,用于计算应该在新选项卡中打开的链接。
我尝试使用:
window.open(url,'_blank');
但是,这会打开一个新窗口。
我还尝试了以下方法:
< form id =oformname =oformaction =方法=posttarget =_ blank>
< / form>
...
document.getElementById(oform)。action = url;
document.getElementById(oform)。submit();
仍然会打开一个新窗口,而不是新标签。
当使用简单的< a href ...>
时, target ='blank'$ c $
是否有解决方案?
CSS3通过属性 target-new
target-new:window |标签|没有;
更新[2016]:此方法从未将其放入CSS3规范,正如其中一条评论所表明的那样。这不应该使用。然而,可以看出大多数现代浏览器无论如何都会在新选项卡中打开 target ='_ blank'
链接,除非尝试立即调整新选项卡的大小。但是,在规范中似乎没有强制这种行为的机制。
[2011]在一个新标签中强制打开,并且支持,请尝试以下操作:
< a href =某个网址目标=_ newtab>锚点的内容< / a>
否则,请使用这个方法可以立即调整窗口大小,以确保弹出窗口阻止程序不会终止弹出窗口。
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?
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
这篇关于我如何在新标签页中打开链接(而不是新窗口)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!