baseURI
只读特性返回绝对基 URL 为
节点
.
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>
元素的
src
attribute or XML
xlink
:href
属性。
In most cases 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 the
xml:base
attribute in XML.
var nodeBaseURI = node.baseURI;
A
DOMString
representing the base URL of the specified
节点
. It may be
null
if unable to obtain an absolute URI. Although this property is read-only, its value may change in certain situations (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 it can be changed:
<base>
tag is found in the document
见 HTML 实时标准的基 URL 章节 了解细节。
可以使用
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
了解细节。
可以使用
以获得元素的基 URL。
element
.baseURI
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM
在该规范中的 Node: baseURI 定义。 |
实时标准 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
baseURI
|
Chrome Yes | Edge 12 | Firefox 1 | IE ? | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android 4 | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
兼容性未知
<base>
元素 (HTML)
xml:base
属性 (XML 文档)。
Node.baseURIObject
- a variant of this API for Mozilla add-ons and internal code. Returns the base URL as an
nsIURI
.
节点
AbortController
AbortSignal
AbstractRange
Attr
ByteString
CDATASection
CSSPrimitiveValue
CSSValue
CSSValueList
CharacterData
ChildNode
注释
CustomEvent
DOMConfiguration
DOMError
DOMErrorHandler
DOMException
DOMImplementation
DOMImplementationList
DOMImplementationRegistry
DOMImplementationSource
DOMLocator
DOMObject
DOMParser
DOMPoint
DOMPointInit
DOMPointReadOnly
DOMRect
DOMString
DOMTimeStamp
DOMTokenList
DOMUserData
Document
DocumentFragment
DocumentType
元素
ElementTraversal
Entity
EntityReference
事件
EventTarget
HTMLCollection
MutationObserver
NodeFilter
NodeIterator
NodeList
NonDocumentTypeChildNode
ProcessingInstruction
PromiseResolver
范围
StaticRange
文本
TextDecoder
TextEncoder
TimeRanges
TreeWalker
TypeInfo
USVString
UserDataHandler
XMLDocument