SVGAElement
The SVGAElement
interface provides access to the properties of an <a>
element, as well as methods to manipulate them.
Properties
This interface also inherits properties from its parent, SVGGraphicsElement
, and implements properties from HTMLHyperlinkElementUtils
.
SVGAElement.download
SVGAElement.href
Read only-
Is an
SVGAnimatedString
that reflects thehref
orxlink:href
attribute. SVGAElement.hreflang
-
Is a
DOMString
that reflects thehreflang
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 bodyPING
will be sent by the browser (in the background). Typically used for tracking. SVGAElement.referrerPolicy
SVGAElement.rel
SVGAElement.relList
SVGAElement.target
Read only-
It corresponds to the
target
attribute of the given element. SVGAElement.text
-
Is a
DOMString
being a synonym for theNode.textContent
property. SVGAElement.type
-
Is a
DOMString
that reflects thetype
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
Specification |
---|
Scalable Vector Graphics (SVG) 1.1 (Second Edition) # InterfaceSVGAElement |
Browser compatibility
BCD tables only load in the browser
See also
- SVG
<a>
element