Navigator: oscpu 屬性

Navigator.oscpu 屬性返回一個字串,用於標識當前作業系統。

一個字串,提供一個標識瀏覽器執行作業系統的字串。

作業系統 oscpuInfo 字串格式
OS/2 OS/2 Warp x (3、4 或 4.5)
Windows CE WindowsCE x.y
Windows 64 位 (64 位構建) Windows NT x.y; Win64; x64
Windows 64 位 (32 位構建) Windows NT x.y; WOW64
Windows 32 位 Windows NT x.y
Mac OS X (PPC 構建) PowerPC Mac OS X 版本 x.y
Mac OS X (i386/x64 構建) Intel Mac OS XmacOS 版本 x.y
Linux 64 位 (32 位構建) uname -s 的輸出,後跟 i686 on x86_64
Linux uname -sm 的輸出

在此表中,x.y 指的是作業系統的版本

示例

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

osInfo(); // alerts "Windows NT 6.0" for example

用法說明

除非您的程式碼是特權的(例如 chrome 或至少具有 UniversalBrowserRead 許可權),否則它可能會獲取 general.oscpu.override 首選項的值,而不是真實的平臺。

規範

規範
HTML
# dom-navigator-oscpu

瀏覽器相容性