HTMLBaseElement: href property
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("HTML DOM")}}
The **href** property of the {{domxref("HTMLBaseElement")}} interface contains a string that is the URL to use as the base for relative URLs.
It reflects the href attribute of the {{HTMLElement("base")}} element.
Value
A string that contains a URL, or the empty string ("") if the corresponding <base> element does not include the href attribute.
Examples
HTML with base URL
This example demonstrates that the href attribute in <base> is reflected in the href property of HTMLBaseElement.
html hidden
js hidden
css hidden
HTML
html
<base href="https://developer.mozilla.org/example" />JavaScript
js
const base = document.getElementsByTagName("base")[0];
log(`base.href="${base.href}"`);Result
{{EmbedLiveSample('HTML with base URL', '100','50px')}}
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}