Navigator:oscpu 属性

已弃用: 不再推荐使用该特性。虽然一些浏览器仍然支持它,但也许已从相关的 web 标准中移除,也许正准备移除或出于兼容性而保留。请尽量不要使用该特性,并更新现有的代码;参见本页面底部的兼容性表格以指导你作出决定。请注意,该特性随时可能无法正常工作。

Navigator.oscpu 属性返回一个字符串,用于标识当前操作系统。

一个字符串,用于标识浏览器运行所在的操作系统。

操作系统 oscpuInfo 字符串格式
OS/2 OS/2 Warp x (either 3, 4 or 4.5)
Windows CE WindowsCE x.y
Windows 64-bit (64-bit build) Windows NT x.y; Win64; x64
Windows 64-bit (32-bit build) Windows NT x.y; WOW64
Windows 32-bit Windows NT x.y
Mac OS X (PPC build) PowerPC Mac OS X version x.y
Mac OS X (i386/x64 build) Intel Mac OS XmacOS version x.y
Linux 64-bit (32-bit build) uname -s 的输出结果,然后是 i686 on x86_64
Linux uname -sm 的输出结果

本表中,x.y 表示操作系统版本。

示例

js
function osInfo() {
  alert(navigator.oscpu);
}

osInfo(); // 示例可能会输出“Windows NT 10.0; Win64; x64”

使用说明

除非你的代码具有特权(例如在 Chrome 中运行或至少具有 UniversalBrowserRead 权限),否则它可能会获取 general.oscpu.override 偏好设置的值,而不是真正的平台信息。

规范

Specification
HTML
# dom-navigator-oscpu

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
oscpu
Deprecated

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
Deprecated. Not for use in new websites.
See implementation notes.