This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The read-only baseURI property of the Node interface returns the absolute base URL of the document containing the node.
The base URL is used to resolve relative URLs when the browser needs to obtain an absolute URL, for example when processing the HTML <img> element's src attribute or the xlink:href Deprecated or href attributes in SVG.
Although this property is read-only, its value is determined by an algorithm each time the property is accessed, and may change if the conditions changed.
The base URL is determined as follows:
window.location).<Base> element in the document, the href value of the first Base element with such an attribute is used instead.A string representing the base URL of the Node.
<output>Not calculated</output>
const output = document.querySelector("output");
output.value = output.baseURI;
<base href="https://developer.mozilla.org/modified_base_uri/" /> <output>Not calculated</output>
const output = document.querySelector("output");
output.value = output.baseURI;
| Specification |
|---|
| DOM> # ref-for-dom-node-baseuri①> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
baseURI |
1 | 12 | 1 | ≤12.1 | ≤4 | 18 | 4 | ≤12.1 | 1 | 1.0 | 4.4 | 1 |
<base> element.
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI