首页 文章

在新标签页或窗口中打开链接[重复]

提问于
浏览
875

这个问题在这里已有答案:

是否可以在新选项卡中打开 a href 链接而不是相同的选项卡?

<a href="http://your_url_here.html">Link</a>

4 回答

  • 203

    <a> 元素的 target 属性设置为 "_tab"

    编辑:它有效,但W3Schools说没有这样的目标属性:http://www.w3schools.com/tags/att_a_target.asp

    编辑2:从我从评论中得出的结论 . 将目标设置为_blank将转到新选项卡或窗口(取决于您的浏览器设置) . 键入除下面之一之外的任何内容将创建一个新的选项卡组(我不确定这些是如何工作的):

    _blank  Opens the linked document in a new window or tab
    _self   Opens the linked document in the same frame as it was clicked (this is default)
    _parent Opens the linked document in the parent frame
    _top    Opens the linked document in the full body of the window
    framename   Opens the linked document in a named frame
    
  • 39

    您不应该决定是否应在新选项卡或新窗口中打开链接,因为最终应该通过用户浏览器的设置来完成此选择 . 有些人喜欢标签;有些像新窗户 .

    使用 _blank 将告诉浏览器使用新的选项卡/窗口,具体取决于用户的浏览器配置以及他们点击链接的方式(例如,中键,Ctrl键或正常点击) .

  • 29

    您应该在锚标记中添加 target="_blank"rel="noopener noreferrer" .

    例如:

    <a target="_blank" rel="noopener noreferrer" href="http://your_url_here.html">Link</a>
    

    资源:

  • 1588

    你可以通过设置 target="_blank" 来做到这一点,w3schools有an example .

相关问题