File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 60822
    
  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...
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Retrieving Windows user in JavaScript - Chrome/Firefox browsers
 
Similar Threads
pass value from struts2 form to javascript
input/output stream
open Word Document from JavaScript
Firefox 3.5 Browser window close using javascript
Chrome sending an extra "GET" with a "POST" preventing an Ajax conversation?