Re: ActiveXObject - Automation Server Cannot Create Object
Followup: I came to tentative understanding of the issue.
Though ActiveXObject is called by JavaScript, but it's not JavaScript
native. It's a proprietary Microsoft object, understood by IE.
Workaround Good-Enough Solution:
In JavaScript (which is embedded in HTML):
// 1. Get the value of Windows local environment variable %USERNAME%
function getUserName() {
if (!document.all) {
alert("Available only with Internet Explorer.");
return;
}
var ws = new ActiveXObject("WScript.Shell");
var un = ws.ExpandEnvironmentStrings("%USERNAME%");
return un;
}
// 2. Write the %USERNAME% value to a cookie.
// Cookie lifespan value is set to "0" days, which means for the
current session only.
createCookie("userName",getUserName(),0);
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
// 3. From GWT side, in Java code, call GWT static method
Cookies.getCookie("userName")
String uName = Cookies.getCookie("userName");
###
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home