Reputation: 1
<html>
<head>
<title>Windows Username</title>
</head>
<body>
<script type="text/javascript">
var WinNetwork = new ActiveXObject("WScript.Network");
alert(WinNetwork.UserName);
</script>
</body>
</html>
I am using this code for getting username, but it is working only for IE. Is there any way I can get it in all browsers?
Upvotes: 0
Views: 7758
Reputation: 16693
In short: You can't. There is no fully compatible alternative in JavaScript, as it poses an unsafe security issue to allow client-side code to become aware of the logged in user. Each browser enforces user detection security differently.
Upvotes: 1