获取有关操作系统的具体信息 [英] Get specifics about operating system
问题描述
我认为这很容易,但我无法弄清楚。
如何判断使用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
$ p $您可以使用系统信息服务获取操作系统版本
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
andwindow.navigator
but on browser startuphiddenDOMWindow
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
ofwindow.navigator
gives all this good stuff, how to get this without having access towindow
?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
andkernel_version
)这篇关于获取有关操作系统的具体信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!