简体   繁体   English

JavaScript 用于 Chrome 扩展 - 获取 Windows 用户名

[英]JavaScript for Chrome extension - get Windows username

I am working on a Chrome extension, where in my JavaScript function should identify the logged in Windows username.我正在开发一个 Chrome 扩展程序,在我的 JavaScript function 中应该识别登录的 Windows 用户名。

I want to access Windows' username within JavaScript and display it in my Chrome extension web page.我想在 JavaScript 中访问 Windows 的用户名,并将其显示在我的 Chrome 扩展程序 web 页面中。

I tried following <script> , this works well in IE.我尝试了<script> ,这在 IE 中运行良好。 Is there any equivalent way possible with the Chrome browser? Chrome浏览器是否有任何等效的方法?

function GetUserName()
    {
        var wshell = new ActiveXObject("WScript.Shell");
        alert(wshell.ExpandEnvironmentStrings("%USERNAME%"));
    }

Please let me know any built-in method to extract the username.请让我知道提取用户名的任何内置方法。

You're using ActiveX which is only available in IE .您正在使用仅在 IE 中可用的 ActiveX In my opinion you should never be able to access information like this from within a browser (and usually can't).在我看来,您永远不能从浏览器中访问这样的信息(通常不能)。 I doubt there is a solution which functions like you want.我怀疑有没有像你想要的那样工作的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM