HTMLBaseElement: 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 July 2015.
Die href
-Eigenschaft des HTMLBaseElement
-Interfaces enthält einen String, der die URL darstellt, die als Basis für relative URLs genutzt wird.
Sie spiegelt das href
-Attribut des <base>
-Elements wider.
Wert
Ein String, der eine URL enthält, oder der leere String (""
), wenn das entsprechende <base>
-Element das href
-Attribut nicht umfasst.
Beispiele
HTML mit Basis-URL
Dieses Beispiel zeigt, dass das href
-Attribut in <base>
in der href
-Eigenschaft des HTMLBaseElement
widergespiegelt wird.
HTML
<base href="https://developer.mozilla.org/example" />
JavaScript
const base = document.getElementsByTagName("base")[0];
log(`base.href="${base.href}"`);
Ergebnis
Spezifikationen
Specification |
---|
HTML # dom-base-href |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
href | ||||||||||||
data: and javascript: urls are not allowed | ||||||||||||
tab, newline, and < are not allowed (dangling markup prevention) |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.