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


Win a copy of OCA Java SE 8 Programmer I Study Guide 1Z0-808 this week in the OCAJP 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: 61968
    
  67

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...
 
Consider Paul's rocket mass heater.
 
subject: Retrieving Windows user in JavaScript - Chrome/Firefox browsers