Javascript get windows username
Posted by Raj
Javascript get windows username.
In this tutorial,I will explain how to get windows username using javascript.
Example1:Retrieve Windows Username with JavaScript Scripting
<html>
<head>
<script language="javascript">
function GetWindowsUserName()
{
var win = new ActiveXObject("WScript.Shell");
var username=(win.ExpandEnvironmentStrings("%USERNAME%"));
alert(username);
}
</script>
</head>
<body OnLoad="GetWindowsUserName();">
</body>
</html>
Example2:Getting windows username in javascript
<script language="javascript" type="text/javascript">
var win = new ActiveXObject("WScript.Network");
alert (win.UserName);
</script>
Note:This code snippet will work only in Internet Explorer because Internet Explorer deals with ActiveX Controls.
In this tutorial,I will explain how to get windows username using javascript.
Example1:Retrieve Windows Username with JavaScript Scripting
<html>
<head>
<script language="javascript">
function GetWindowsUserName()
{
var win = new ActiveXObject("WScript.Shell");
var username=(win.ExpandEnvironmentStrings("%USERNAME%"));
alert(username);
}
</script>
</head>
<body OnLoad="GetWindowsUserName();">
</body>
</html>
Example2:Getting windows username in javascript
<script language="javascript" type="text/javascript">
var win = new ActiveXObject("WScript.Network");
alert (win.UserName);
</script>
Note:This code snippet will work only in Internet Explorer because Internet Explorer deals with ActiveX Controls.
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
get windows username,
get windows username using javascript,
Getting windows username in javascript,
JAVASCRIPT,
Retrieve Windows Username with JavaScript Scripting
.You can leave a response, or trackback from your own site.