target=“_blank” vs. target=“_new”

2019-01-01 14:20发布

What's the difference between <a target="_new"> and <a target="_blank"> and which should I use if I just want to open a link in a new tab/window?

标签: html
12条回答
刘海飞了
2楼-- · 2019-01-01 14:40
  • _blank as a target value will spawn a new window every time,
  • _new will only spawn one new window.

Also, every link clicked with a target value of _new will replace the page loaded in the previously spawned window.

You can click here When to use _blank or _new to try it out for yourself.

查看更多
弹指情弦暗扣
3楼-- · 2019-01-01 14:44

TL;DR
USE _blank

The target attribute specifies where to open the linked document.

USAGE: target="xyz"  [don't forget double quotes]

_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

SINCE "_new" is not any of these IT WILL COME UNDER "framename" so if a user re-clicks on that hyperlink it will not open a new tab instead update the existing tab. Whereas in _blank if user clicks twice then 2 new tabs open.

查看更多
妖精总统
4楼-- · 2019-01-01 14:45

This may have been asked before but:

"every link that specifies target="_new" looks for and finds that window by name, and opens in it.

If you use target="_blank," a brand new window will be created each time, on top of the current window."

from here: http://thedesignspace.net/MT2archives/000316.html

查看更多
伤终究还是伤i
5楼-- · 2019-01-01 14:49

Caution - remember to always include the "quotes" - at least on Chrome, target=_blank (no quotes) is NOT THE SAME as target="_blank" (with quotes).

The latter opens each link in a new tab/window. The former (missing quotes) opens the first link you click in one new tab/window, then overwrites that same tab/window with each subsequent link you click (that's named also with the missing quotes).

查看更多
爱死公子算了
6楼-- · 2019-01-01 14:49

The use of _New is useful when working on pages that are Iframed. Since target="_blank" doesn't do the trick and opens the page on the same iframe... target new is the best solution for Iframe Pages. Just my five cents.

查看更多
不流泪的眼
7楼-- · 2019-01-01 14:50

target="_blank" opens a new tab in most browsers.

查看更多
登录 后发表回答