Sudheer
Sudheer

Reputation: 1

How to get Windows username using javascript for all browsers?

<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

Answers (1)

Koby Douek
Koby Douek

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

Related Questions