First things first.
It is not possible*
Browsers are not allowed to access such sensitive information. It will cause a huge security threat.
*- Now coming to the asterix.
The only way to get windows user info using javascript is using ActiveX. It will only work in internet explorer. So it is safe to say that there is no accepted way to do this globally.
If you still want to go ahead and get it through internet explorer, then here is the treat you are looking for,
<script language="javascript">
function GetUserName()
{
var winShell= new ActiveXObject("WScript.Shell");
alert(winShell.ExpandEnvironmentStrings("%USERNAME%"));
}
</script>
Trying to get the user information using JavaScript is a feeble way. Just make a server call through ajax or which ever method you are comfortable with. Then pass on the retrieved user info to JavaScript and do whatever you requirement demands you to.