aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Retrieving Windows user in JavaScript - Chrome/Firefox browsers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Retrieving Windows user in JavaScript - Chrome/Firefox browsers" Watch "Retrieving Windows user in JavaScript - Chrome/Firefox browsers" New topic
Author

Retrieving Windows user in JavaScript - Chrome/Firefox browsers

Venkataprasath Padmanabhan
Greenhorn

Joined: Jul 14, 2011
Posts: 10
Hi,

How to retrieve logged in windows user name from a javascript,the following piece of code works only in IE, but my app has to work in Chrome, Firefox and Safari as well. Any help would be appreciated.

<html>
<head>
<script language="javascript">
function GetUserName()
{
var wshell = new ActiveXObject("WScript.Shell");
alert(wshell.ExpandEnvironmentStrings("%USERNAME%"));
}
</script>
</head>
<body OnLoad="GetUserName();">
</body>
</html>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60994
    
  65

ActiveX will only ever work with IE so you are out of luck.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Venkataprasath Padmanabhan
Greenhorn

Joined: Jul 14, 2011
Posts: 10
I think I was chasing a wild goose, I found a framework WAFFLE http://waffle.codeplex.com/ which nicely integrates with Spring Security to retrieve windows user and domain details on the server side which would fit exactly my requirement...

Thanks to WAFFLE...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieving Windows user in JavaScript - Chrome/Firefox browsers