Blogs

Paul Kimmel's Blog

Getting Client User and Special Folder Information with JavaScript

     

You may on occasion want to query client information for your Web application using JavaScript. You can get this information by enabling unsigned ActiveX objects in IE and a couple of lines of code. The first short listing will return the client user information and the second short listing demonstrates how to return the path to special file folders for the user.

var o = new ActiveXObject("WScript.Network");
alert(o.UserName);

var path = w.SpecialFolders("MyDocuments");
alert(path);

To enable unsigned ActiveX objects select  Tools|Internet Options and select the Security tab. Select the zone like Local intranet, click the Custom level button. Scroll down to the “Initialize and script ActiveX controls not marked as safe for scripting and change it to Enable or Prompt (see the Figure).

image
Figure 1: You can run ActiveX objects in your JavaScript for clients running IE.

You may encounter different challenges in different zones. For example, running an application from the Internet may not work because of permissions set by network administrators that override all permissions. Unfortunately I am not aware of all possible combinations. Code like that above might be ideally suited for utility applications that run on a local PC only in the Intranet zone.

Maybe some of our smart, savvy customers can respond and add to this blog post.

Published Jun 02 2009, 07:44 PM by Paul Kimmel (DevExpress)
Bookmark and Share

Comments

No Comments
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.