SVGAElement: href-Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.

Die href-Eigenschaft, die schreibgeschützt ist, des SVGAElement gibt ein SVGAnimatedString-Objekt zurück, das den Wert des href-Attributs widerspiegelt und in bestimmten Fällen das xlink:href-Attribut Veraltet . Es gibt das Ziel-URI an, das mit dem Link verknüpft ist.

Diese Eigenschaft ermöglicht den Zugriff auf das URI, das für einen Link innerhalb eines SVG-Dokuments festgelegt wurde.

Wert

Ein SVGAnimatedString, das den Wert des href-Attributs angibt. Darüber hinaus spiegelt es für Elemente, die dies unterstützen, den Wert des xlink:href-Attributs Veraltet wider, wenn das href-Attribut nicht gesetzt ist.

Beispiele

js
// Select an SVG <a> element
const svgLink = document.querySelector("a");

// Access the href property
console.log(svgLink.href.baseVal); // Logs the base URI
console.log(svgLink.href.animVal); // Logs the animated URI if applicable

// Example: Reflecting xlink:href
const deprecatedLink = document.querySelector("a");
console.log(deprecatedLink.href.baseVal); // Reflects 'xlink:href' if 'href' is not set

Spezifikationen

Specification
Scalable Vector Graphics (SVG) 2
# __svg__SVGURIReference__href

Browser-Kompatibilität

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
href

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Siehe auch