web api interface
SVGAElement
The SVGAElement interface provides access to the properties of an <a> element, as well as methods to manipulate them.
Instance properties
This interface also inherits properties from its parent, SVGGraphicsElement.
download- : A string indicating that the linked resource is intended to be downloaded rather than displayed in the browser.
hash- : A string representing the fragment identifier, including the leading hash mark (
#), if any, in the referenced URL.
- : A string representing the fragment identifier, including the leading hash mark (
host- : A string representing the hostname and port (if it’s not the default port) in the referenced URL.
hostname- : A string representing the hostname in the referenced URL.
hrefRead only- : An
SVGAnimatedStringthat reflects thehreforxlink:hrefDeprecated attribute.
- : An
hreflang- : A string indicating the language of the linked resource.
interestForElementExperimental- : Gets or sets the target element of an interest invoker, in cases where the associated
<a>element is specified as an interest invoker.
- : Gets or sets the target element of an interest invoker, in cases where the associated
originRead only- : Returns a string containing the origin of the URL — that is, its scheme, its domain and its port.
pathname- : A string containing an initial
/followed by the path of the URL, not including the query string or fragment.
- : A string containing an initial
password- : A string containing the password specified before the domain name.
ping- : A string that reflects the
pingattribute, containing a space-separated list of URLs to which, when the hyperlink is followed,POSTrequests with the bodyPINGwill be sent by the browser (in the background). Typically used for tracking.
- : A string that reflects the
port- : A string representing the port component, if any, of the referenced URL.
protocol- : A string representing the protocol component, including trailing colon (
:), of the referenced URL.
- : A string representing the protocol component, including trailing colon (
referrerPolicyrel- : A string reflecting the
relSVG attribute, specifying the relationship of the link’s target.
- : A string reflecting the
relList- : A
DOMTokenListreflecting therelSVG attribute, as a list of tokens.
- : A
search- : A string representing the URL’s query string, if any, including the leading question mark (
?).
- : A string representing the URL’s query string, if any, including the leading question mark (
targetRead only- : It corresponds to the
targetattribute of the given element.
- : It corresponds to the
textDeprecated- : A string that is a synonym for the
textContentproperty.
- : A string that is a synonym for the
type- : A string that reflects the
typeattribute, indicating the MIME type of the linked resource.
- : A string that reflects the
username- : A string containing the username specified before the domain name.
Instance 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.
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
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
See also
- SVG
<a>element