--- title: target slug: Web/SVG/Attribute/target translation_of: Web/SVG/Attribute/target ---
target
当结束资源有多个可能的目标时,例如,当父文档嵌入在HTML或XHTML文档中或使用选项卡式浏览器查看时,应使用该属性。此属性指定激活链接时要在其中打开文档的浏览上下文的名称(例如,浏览器选项卡或(X)HTML iframe或object元素):
只有一个元素正在使用此属性:{{SVGElement("a")}}
html, body, svg { height: 100%; } text { font: 20px Arial, Helvetica, sans-serif; fill: blue; text-decoration: underline; }
<svg viewBox="0 0 300 120" xmlns="http://www.w3.org/2000/svg"> <a href="https://developer.mozilla.org" target="_self"> <text x="0" y="20">在iframe中打开链接</text> </a> <a href="https://developer.mozilla.org" target="_blank"> <text x="0" y="60">在新标签页或窗口中打开链接</text> </a> <a href="https://developer.mozilla.org" target="_top"> <text x="0" y="100">在此标签或窗口中打开链接</text> </a> </svg>
{{EmbedLiveSample("topExample", "300", "120")}}
值 | _self | _parent | _top | _blank |<XML-Name> |
---|---|
默认值 | _self |
可动画的 | 是 |
_replace
{{deprecated_inline}}当前SVG图像被与当前SVG图像在同一帧中相同矩形区域中的链接内容替换。
注意:这个值是从来没有很好的执行,之间的区别_replace
,并_self
已通过在浏览上下文的HTML定义的变化变得多余。使用_self
以取代目前的SVG文件。
_self
_parent
_top
_blank
<XML-Name>
规格 | 状态 | 评论 |
---|---|---|
{{SpecName("SVG2", "linking.html#AElementTargetAttribute", "target")}} | {{Spec2("SVG2")}} | 删除_replace 值。 |
{{SpecName("SVG1.1", "linking.html#AElementTargetAttribute", "target")}} | {{Spec2("SVG1.1")}} | 初始定义 |
{{Compat("svg.elements.a.target")}}