简体   繁体   中英

Is there any way to get windows username in google chrome using JavaScript?

I want to get the OS username with JavaScript for cross browser. I had been trying the different solutions for this but none actually worked. I don't actually want to install 3rd party plugin as according to my requirement I can't do that.

This is so far I get on the web while surfing for the solution

    var wshshell = new ActiveXObject("wscript.shell");
    var username = wshshell.ExpandEnvironmentStrings("%username%");
    alert(username);

Sorry, this is impossible. Webpages cannot access the OS (Operating System) because this would be an issue for security.

The code you found only works in IE and when the user sets your page to the lowest security level (you cannot rely on this).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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