过时
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.
过时 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
prefix 弃用 非标 Chrome No Edge 12 — 79 Firefox 1 — 48
不支持 1 — 48
This API was moved to the 元素 and Attr APIs according to the DOM4 standard.
5
this property was read-write; starting with Firefox 5.0 it is read-only, following the specification.
IE Yes
Yes
Only supported on 元素 .
Opera No Safari Yes WebView Android No Chrome Android No Firefox Android 9 Opera Android No Safari iOS ? Samsung Internet Android No

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

非标。预期跨浏览器支持较差。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

见实现注意事项。

另请参阅

元数据

  • 最后修改: