Get Windows username in a legacy (not WebExtensions) Firefox add-on

前端 未结 5 1244
盖世英雄少女心
盖世英雄少女心 2020-11-29 07:17

I am working a Firefox add-on (which is written in JavaScript) and need to determine the Windows user currently logged on. Is there a way to do this?

5条回答
  •  春和景丽
    2020-11-29 08:06

    Following code works for me instead of onload event with function calling:

    var objUserInfo = new ActiveXObject("WScript.network");
    document.write(objUserInfo.ComputerName+"
    "); document.write(objUserInfo.UserDomain+"
    "); document.write(objUserInfo.UserName+"
    "); var uname = objUserInfo.UserName; alert(uname);

提交回复
热议问题