Ren*_*ene 1021 html tabs window href hyperlink
是否可以a href
在新选项卡中打开链接而不是相同的选项卡?
<a href="http://your_url_here.html">Link</a>
Run Code Online (Sandbox Code Playgroud)
Nat*_*han 1829
您应该在锚标记中添加target="_blank"
和rel="noopener noreferrer"
.
例如:
<a target="_blank" rel="noopener noreferrer" href="http://your_url_here.html">Link</a>
Run Code Online (Sandbox Code Playgroud)
资源:
rel="noopener noreferrer"
| 属性<a>
Gau*_*ier 209
您不应该决定是否应该在新标签页或新窗口中打开链接,因为最终应该通过用户浏览器的设置来完成此选择.有些人喜欢标签; 有些像新窗户.
使用_blank
将告诉浏览器使用新的选项卡/窗口,具体取决于用户的浏览器配置以及他们如何单击链接(例如,中键单击,Ctrl+单击或正常单击).
Too*_*ele 44
设置元素的target
属性<a>
"_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
Run Code Online (Sandbox Code Playgroud)