The Node.baseURI
read-only property returns the absolute base URL of a 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 XML xlink:href
attribute.
In the common case the base URL is simply the location of the document, but it can be affected by many factors, including the <base>
element in HTML and xml:base
attribute in XML.
var baseURI = node.baseURI;
baseURI
is a DOMString
representing the base URL of the specified Node
. May be null
if unable to obtain an absolute URInode.baseURI
is read-only.node.baseURI
may change with time (see below).The base URL of a document defaults to the document's address (as displayed by the browser and available in window.location
), but can change from the default:
<base>
tag is found in the document;See the Base URLs section of the HTML Living standard for details.
You can use
to obtain the base URL of a document. Note that obtaining the base URL for a document may return different URLs over time if the document
.baseURI<base>
tags or the document's location change.
The base URL of an element in HTML normally equals the base URL of the document the node is in.
If the document contains xml:base
attributes (which you shouldn't do in HTML documents), the element.baseURI
takes the xml:base
attributes of element's parents into account when computing the base URL. See xml:base for details.
You can use
to obtain the base URL of an element.element
.baseURI
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | 12 | ? | ? | ? | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | ? | ? | ? | ? | Yes |
<base>
element (HTML)xml:base
attribute (XML documents).Node.baseURIObject
- a variant of this API for Mozilla add-ons and internal code. Returns the base URL as an nsIURI
.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Node/baseURI