2009-09-13 144 views

回答

15

    // Returns "WINNT" on Windows Vista, XP, 2000, and NT systems; 
    // "Linux" on GNU/Linux; and "Darwin" on Mac OS X. 
    var osString = Components.classes["@mozilla.org/xre/app-info;1"] 
        .getService(Components.interfaces.nsIXULRuntime).OS; 
+0

僅供參考:https://developer.mozilla.org/en/nsIXULRuntime – Nickolay 2009-10-12 06:22:14

0

爲了完整,讓OS字符串新addon-sdk

const {Cc, Ci} = require("chrome"); 
const osString = Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULRuntime).OS; 
console.log(osString);