【问题标题】:Open up in a tab not a window [duplicate]在标签而不是窗口中打开[重复]
【发布时间】:2012-04-29 01:18:04
【问题描述】:

可能重复:
Open url in new tab using javascript

我正在尝试使某些内容在选项卡中打开,而不是在窗口中打开。据我所知,这是由浏览器偏好设置的。没有真正的方法可以覆盖它吗?我知道您可以使用 window.open,但这取决于浏览器的偏好吗?我目前正在使用 target="_blank"。

【问题讨论】:

标签: javascript


【解决方案1】:

您可以使用以下 CSS 来做到这一点:

a {
    target-name: new;
    target-new: tab;
}​​​​​​​​​​​​​

See this example(请不要因为 jsFiddle 不支持选项卡,所以它不起作用。仅用于演示目的)

作为简单的一行解决方案:

<a href="http://www.bbc.com" target="new" style="target-name:new;target-new:tab">
    Text
</a>​

【讨论】:

    【解决方案2】:

    目前,您确实无法在新选项卡而不是新窗口中打开它。正如您所说,这是一种浏览器偏好。

    关于jacktheripper 的回应。似乎任何主流浏览器都不支持 target-name 属性*。

    *CSS3 target-name Property

    【讨论】:

      猜你喜欢
      • 2014-05-13
      • 2013-04-11
      • 2012-09-01
      • 2015-06-11
      • 2012-10-08
      • 2014-10-15
      • 2017-12-02
      • 2017-04-07
      相关资源
      最近更新 更多