I am working on a Chrome extension, where in my JavaScript function should identify the logged in Windows username.
I want to access Windows' username within JavaScript and display it in my Chrome extension web page.
I tried following <script>
, this works well i开发者_如何学运维n IE. Is there any equivalent way possible with the Chrome browser?
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. 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.
精彩评论