target - SVG: Scalable Vector Graphics 编辑

The target attribute should be used when there are multiple possible targets for the ending resource, such as when the parent document is embedded within an HTML or XHTML document, or is viewed with a tabbed browser. This attribute specifies the name of the browsing context (e.g., a browser tab or an (X)HTML iframe or object element) into which a document is to be opened when the link is activated:

Only one element is using this attribute: <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">Open link within iframe</text>
  </a>
  <a href="https://developer.mozilla.org" target="_blank">
    <text x="0" y="60">Open link in new tab or window</text>
  </a>
  <a href="https://developer.mozilla.org" target="_top">
    <text x="0" y="100">Open link in this tab or window</text>
  </a>
</svg>

Usage notes

Value_self | _parent | _top | _blank | <XML-Name>
Default value_self
AnimatableYes
_replace This deprecated API should no longer be used, but will probably still work.

The current SVG image is replaced by the linked content in the same rectangular area in the same frame as the current SVG image.

Note: This value was never well implemented, and the distinction between _replace and _self has been made redundant by changes in the HTML definition of browsing contexts. Use _self to replace the current SVG document.

_self
The current SVG image is replaced by the linked content in the same browsing context as the current SVG image.
_parent
The immediate parent browsing context of the SVG image is replaced by the linked content, if it exists and can be securely accessed from this document.
_top
The content of the full active window or tab is replaced by the linked content, if it exists and can be securely accessed from this document
_blank
A new un-named window or tab is requested for the display of the linked content, if this document can securely do so. If the user agent does not support multiple windows/tabs, the result is the same as _top.
<XML-Name>
Specifies the name of the browsing context (tab, inline frame, object, etc.) for display of the linked content. If a context with this name already exists, and can be securely accessed from this document, it is re-used, replacing the existing content. If it does not exist, it is created (the same as '_blank', except that it now has a name). The name must be a valid XML Name [XML11], and should not start with an underscore (U+005F LOW LINE character), to meet the requirements of a valid browsing context name from HTML.

Specifications

SpecificationStatusComment
Scalable Vector Graphics (SVG) 2
The definition of 'target' in that specification.
Candidate RecommendationRemoved the _replace value.
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'target' in that specification.
RecommendationInitial definition

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:100 次

字数:6130

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文