目标= QUOT; _blank" vs target =“_new” [英] target="_blank" vs. target="_new"
问题描述
根据 HTML5规范: 有效的浏览上下文名称是任何至少包含一个字符的字符串,不以U + 005F LOW LINE字符开头。 (以下划线开头的名字是为特殊关键字保留的。) 有效的浏览上下文名称或关键字是任何有效的字符串浏览上下文名称,或者这是对_blank,_self,_parent或_top之一的ASCII区分大小写匹配。 - Source 这意味着没有<$ c这样的关键字HTML5中的$ c> _new ,以及而不是在HTML4(也就是XHTML)中,也就是说,如果你使用这个值作为目标属性的值,将不会有任何一致的行为。 正如Daniel和Michael在评论中指出的那样,当使用target What's the difference between According to the HTML5 Spec: A valid browsing context name is any string with at least one character that does not start with a U+005F LOW LINE character. (Names starting with an underscore are reserved for special keywords.) A valid browsing context name or keyword is any string that is either a valid browsing context name or that is an ASCII case-insensitive match for one of: _blank, _self, _parent, or _top." - Source That means that there is no such keyword as As Daniel and Michael have pointed out in the comments, when using target 这篇关于目标= QUOT; _blank" vs target =“_new”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!< a target =_ blank>
,如果我只想在新标签页/窗口中打开链接,应该使用哪一个? 使用 _blank
$ b
< h3>安全建议
_blank
指向一个不可信网站,您应该另外设置 rel =no开瓶器
。这可以防止开放网站通过JavaScript混淆opener。有关详情,请参阅此文章。<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?Use "_blank"
_new
in HTML5, and not in HTML4 (and consequently XHTML) either. That means, that there will be no consistent behavior whatsoever if you use this as a value for the target attribute.Security recommendation
_blank
pointing to an untrusted website, you should, in addition, set rel="noopener"
. This prevents the opening site to mess with the opener via JavaScript. See this post for more information.