SVGAElement - Web APIs 编辑

The SVGAElement interface provides access to the properties of <a> element, as well as methods to manipulate them.

Properties

This interface also inherits properties from its parent, SVGGraphicsElement, and implements properties from SVGURIReference and HTMLHyperlinkElementUtils.

SVGAElement.download
See HTMLAnchorElement.download.
SVGAElement.href
See HTMLAnchorElement.href.
SVGAElement.hreflang
Is a DOMString that reflects the hreflang attribute, indicating the language of the linked resource.
SVGAElement.ping
Is a DOMString that reflects the ping attribute, containing a space-separated list of URLs to which, when the hyperlink is followed, POST requests with the body PING will be sent by the browser (in the background). Typically used for tracking.
SVGAElement.referrerPolicy
See HTMLAnchorElement.referrerPolicy.
SVGAElement.rel
See HTMLAnchorElement.rel.
SVGAElement.relList
See HTMLAnchorElement.relList.
SVGAElement.target Read only
It corresponds to the target attribute of the given element.
SVGAElement.text
Is a DOMString being a synonym for the Node.textContent property.
SVGAElement.type
Is a DOMString that reflects the type attribute, indicating the MIME type of the linked resource.

Methods

This interface has no methods but inherits methods from its parent, SVGGraphicsElement.

Example

In the example below, the target attribute of the <a> element is set to _blank and when the link is clicked, it logs to notify whether the condition is met or not.

var linkRef = document.querySelector("a");
linkRef.target = "_self";

linkRef.onclick = function(){
  if (linkRef.target === "_blank") {
    console.log("BLANK!");
    linkRef.target = "_self";
  } else {
    console.log("SORRY! not _blank");
  }
} 

Specifications

SpecificationStatusComment
Scalable Vector Graphics (SVG) 2Candidate RecommendationReplaced inheritance from SVGElement by SVGGraphicsElement and removed the interface implementations of SVGTests, SVGLangSpace, SVGExternalResourcesRequired, SVGStylable, and SVGTransformable by HTMLHyperlinkElementUtils
Scalable Vector Graphics (SVG) 1.1 (Second Edition)RecommendationInitial definition

Browser compatibility

BCD tables only load in the browser

See also

  • SVG <a> element

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

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

发布评论

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

词条统计

浏览:110 次

字数:7710

最后编辑:8 年前

编辑次数:0 次

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