获取有关操作系统的详细信息 [英] Get specifics about operating system

查看:36
本文介绍了获取有关操作系统的详细信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以为这很容易,但我想不通.

I thought this would be easy but I can't figure this out.

如何判断使用的是Win7还是WinXP?就像操作系统的细节一样.Linux 应该给出细节.Mac OS 版本等

How to tell if using Win7 or WinXP? Like details on operating system. Linux should give specifics. Mac OS version etc.

我想从 Services.appShell.hiddenDOMWindowwindow.navigator 读取用户代理,但在浏览器启动时 hiddenDOMWindow 尚未加载.

I thought to read user agent from Services.appShell.hiddenDOMWindow and window.navigator but on browser startup hiddenDOMWindow isn't loaded yet.

现在我只能从以下位置获取 WINNT:

Right now I can only get WINNT from:

Components.utils.import("resource://gre/modules/osfile.jsm")
console.log(OS.Constants.Sys.Name)

console.log(Services.appinfo.OS)

window.navigator

console.log 提供了所有这些好东西,如何在不访问 window 的情况下获得这些?

console.log of window.navigator gives all this good stuff, how to get this without having access to window?

appCodeName:"Mozilla"
appName:"Netscape"
appVersion:"5.0 (Windows)"
battery:BatteryManager
buildID:"20140529161749"
cookieEnabled:true
doNotTrack:"yes"
geolocation:Geolocation
language:"en-US"
mimeTypes:MimeTypeArray
mozAlarms:null
mozApps:XPCWrappedNative_NoHelper
mozCameras:CameraManager
mozConnection:MozConnection
mozContacts:ContactManager
mozId:null
mozKeyboard:XPCWrappedNative_NoHelper
mozPay:null
mozPermissionSettings:null
mozPhoneNumberService:PhoneNumberService
mozPower:MozPowerManager
mozTCPSocket:null
onLine:true
oscpu:"Windows NT 5.1"
platform:"Win32"
plugins:PluginArray
product:"Gecko"
productSub:"20100101"
userAgent:"Mozilla/5.0 (Windows NT 5.1; rv:30.0) Gecko/20100101 Firefox/30.0"
vendor:""
vendorSub:""
__proto__:NavigatorPrototype

推荐答案

可以使用系统信息服务.获取操作系统版本

You can use the system info service. To get the OS version

Services.sysinfo.getProperty("version");

请参阅来源以了解支持的属性.还要注意它们特定于平台的含义(例如,在 Android 上有 versionkernel_version)

Consult the sources for the properties supported. Also pay attention to their platform-specific meaning (e.g. on Android there is version and kernel_version)

这篇关于获取有关操作系统的详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆