Back to Content

SVGAElement

files/en-us/web/api/svgaelement/index.md

latest4.2 KB
Original Source

{{APIRef("SVG")}}

The SVGAElement interface provides access to the properties of an {{SVGElement("a")}} element, as well as methods to manipulate them.

{{InheritanceDiagram}}

Instance properties

This interface also inherits properties from its parent, {{domxref("SVGGraphicsElement")}}.

  • {{domxref("SVGAElement.download")}}
    • : A string indicating that the linked resource is intended to be downloaded rather than displayed in the browser.
  • {{domxref("SVGAElement.hash")}}
    • : A string representing the fragment identifier, including the leading hash mark (#), if any, in the referenced URL.
  • {{domxref("SVGAElement.host")}}
    • : A string representing the hostname and port (if it's not the default port) in the referenced URL.
  • {{domxref("SVGAElement.hostname")}}
    • : A string representing the hostname in the referenced URL.
  • {{domxref("SVGAElement.href")}} {{ReadOnlyInline}}
    • : An {{domxref("SVGAnimatedString")}} that reflects the {{SVGAttr("href")}} or {{SVGAttr("xlink:href")}} {{deprecated_inline}} attribute.
  • {{domxref("SVGAElement.hreflang")}}
    • : A string indicating the language of the linked resource.
  • {{domxref("SVGAElement.interestForElement")}} {{experimental_inline}} {{non-standard_inline}}
    • : Gets or sets the target element of an interest invoker, in cases where the associated {{svgelement("a")}} element is specified as an interest invoker.
  • {{domxref("SVGAElement.origin")}} {{ReadOnlyInline}}
    • : Returns a string containing the origin of the URL — that is, its scheme, its domain and its port.
  • {{domxref("SVGAElement.pathname")}}
    • : A string containing an initial / followed by the path of the URL, not including the query string or fragment.
  • {{domxref("SVGAElement.password")}}
    • : A string containing the password specified before the domain name.
  • {{domxref("SVGAElement.ping")}}
    • : A string that reflects the ping attribute, containing a space-separated list of URLs to which, when the hyperlink is followed, {{HTTPMethod("POST")}} requests with the body PING will be sent by the browser (in the background). Typically used for tracking.
  • {{domxref("SVGAElement.port")}}
    • : A string representing the port component, if any, of the referenced URL.
  • {{domxref("SVGAElement.protocol")}}
    • : A string representing the protocol component, including trailing colon (:), of the referenced URL.
  • {{domxref("SVGAElement.referrerPolicy")}}
    • : A string specifying which referrer to send when fetching the URL.
  • {{domxref("SVGAElement.rel")}}
    • : A string reflecting the rel SVG attribute, specifying the relationship of the link's target.
  • {{domxref("SVGAElement.relList")}}
    • : A {{domxref("DOMTokenList")}} reflecting the rel SVG attribute, as a list of tokens.
  • {{domxref("SVGAElement.search")}}
    • : A string representing the URL's query string, if any, including the leading question mark (?).
  • {{domxref("SVGAElement.target")}} {{ReadOnlyInline}}
    • : It corresponds to the {{SVGAttr("target")}} attribute of the given element.
  • {{domxref("SVGAElement.text")}} {{deprecated_inline}}
    • : A string that is a synonym for the {{domxref("Node.textContent")}} property.
  • {{domxref("SVGAElement.type")}}
    • : A string that reflects the type attribute, indicating the MIME type of the linked resource.
  • {{domxref("SVGAElement.username")}}
    • : A string containing the username specified before the domain name.

Instance methods

This interface has no methods but inherits methods from its parent, {{domxref("SVGGraphicsElement")}}.

Example

In the example below, the {{SVGAttr("target")}} attribute of the {{SVGElement("a")}} element is set to _blank and when the link is clicked, it logs to notify whether the condition is met or not.

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

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

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • SVG {{SVGElement("a")}} element