Getting windows username in javascript
Here's the code to get windows username in javascript.
<script language="javascript" type="text/javascript">
var WshNetwork = new ActiveXObject("WScript.Network");
alert (WshNetwork.UserName);
</script>
This code snippet will work only in Internet Explorer because Internet Explorer deals with ActiveX Controls. ActiveX is famous for bad security that's why web browsers such as Mozilla Firefox, Google Chrome doesn;t support this.
To get the windows username through just JavaScript is also a big security risk. Therefore it uses ActiveX to get windows username of currently login user.
Labels: javascript
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment