【问题标题】:Opening link in new tab without moving away from the active tab (and without taking user to the new tab) in HTML <a> tag在 HTML <a> 标记中打开新选项卡中的链接而不离开活动选项卡(并且不将用户带到新选项卡)
【发布时间】:2016-09-29 07:06:29
【问题描述】:

当我使用&lt;a href="some url" target="_blank"&gt; 并且当用户点击相应的链接时,新标签页打开并且用户被定向到新标签页。

我希望新标签应该打开,但用户应该只保留在前一个标签上。换句话说,我想模拟 Ctrl+click(或 Mac 中的 Cmd+click)行为。

target 属性是否有任何此类值,或者是否有任何其他属性可以将此类属性设置为链接 (&lt;a ...&gt;)?

【问题讨论】:

标签: html hyperlink tabs anchor target


【解决方案1】:

试试这个

<a href="www.stackoverflow.com" onclick="window.open('#','_blank');window.open(this.href,'_self');">
    linktext
</a>

【讨论】:

    猜你喜欢
    • 2012-04-25
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多