过时
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
Node.prefix
read-only property returns the namespace prefix of the specified node, or
null
if no prefix is specified.
In DOM4 this API was moved from
节点
到
元素
and
Attr
接口。
string = node.prefix
The following logs "x" to the console.
<x:div onclick="console.log(this.prefix)"/>
This will only work when a namespace-aware parser is used, i.e. when a document is served with an XML MIME type. This will not work for HTML documents.
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM (文档对象模型) 3 级核心规范
The definition of 'Node.prefix' in that specification. |
过时 |
Specifies the behavior when it's set to
null
.
|
|
DOM (文档对象模型) 级别 2 核心规范
The definition of 'Initial definition' in that specification. |
过时 | 初始定义 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
prefix
弃用
非标
|
Chrome No | Edge 12 — 79 |
Firefox
1 — 48
|
IE
Yes
|
Opera No | Safari Yes | WebView Android No | Chrome Android No | Firefox Android 9 | Opera Android No | Safari iOS ? | Samsung Internet Android No |
完整支持
不支持
兼容性未知
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
见实现注意事项。
节点
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