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

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

问题描述

我认为这很容易,但我无法弄清楚。



如何判断使用Win7还是WinXP?喜欢操作系统的细节。 Linux应该给出具体的细节。 Mac OS版本等。



我想从 Services.appShell.hiddenDOMWindow window.navigator 但是在浏览器启动时 hiddenDOMWindow 尚未加载。

现在我只能从 $ b

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



  console.log(Services.appinfo.OS)

console.log 窗口.navigator 给出了所有这些好东西,如何在不访问窗口

  appCodeName:Mozilla
appName:Netscape
appVersion:5.0(Windows)
电池:BatteryManager
buildID :20140529161749
cookieEnabled:true
doNotTrack:yes
geolocation:Geolocation
语言:en-US
mimeTypes:MimeTypeArray
mozAla rms:null
mozApps:XPCWrappedNative_NoHelper
mozCameras:CameraManager
mozConnection:MozConnection
mozContacts:ContactManager
mozId:null
mozKeyboard:XPCWrappedNative_NoHelper $ b $ 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
 

class =lang-js prettyprint-override> Services.sysinfo.getProperty(version);

请参阅来源 (例如,在Android上有 version kernel_version


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

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

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

Right now I can only get WINNT from:

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

or

console.log(Services.appinfo.OS)

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");

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天全站免登陆