JavaScript
  Home arrow JavaScript arrow Page 5 - Advanced JavaScript with Internet Explorer...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVASCRIPT

Advanced JavaScript with Internet Explorer: Working with Drives and More
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2006-03-28

    Table of Contents:
  • Advanced JavaScript with Internet Explorer: Working with Drives and More
  • A better approach to retrieving a list of drives using JavaScript
  • How to know the number of partitions of each physical drive using JavaScript
  • How to learn more information about each partition using JavaScript
  • How to list all folder/file information (including sub-folders) using JavaScript
  • How to list all folder information for a particular sub-folder using JavaScript

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Advanced JavaScript with Internet Explorer: Working with Drives and More - How to list all folder/file information (including sub-folders) using JavaScript


    (Page 5 of 6 )

    Now, let us try to develop a simple script (JavaScript) which shows a technique for retrieving the number of partitions of each drive on a web page. The entire code for the sample is as follows:

    <!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
          <head>
                <title></title>
                <meta  name="GENERATOR"  content="Microsoft Visual Studio .NET
    7.1">
                <meta  name="vs_targetSchema"
     content="http://schemas.microsoft.com/intellisense/ie5">
          <script  id=clientEventHandlersJS  language=javascript>
    <!--

    function Button1_onclick() {
          var locator = new ActiveXObject ("WbemScripting.SWbemLocator");
          var service = locator.ConnectServer(".");
          var properties = service.ExecQuery("SELECT * FROM Win32_Directory");
          var e = new Enumerator (properties);
          document.write("<table border=1>");
          for (;!e.atEnd();e.moveNext ())
          {
                var p = e.item ();
                document.write("<tr>");
                document.write("<td>" + p.FileName + "</td>");
                document.write("<td>" + p.Path + "</td>");
                document.write("<td>" + p.Readable + "</td>");
                document.write("<td>" + p.Writable + "</td>");
                document.write("</tr>");
          }
          document.write("</table>");
    }

    //-->
    </script>
    </head>
          <body>
                <INPUT  id="Button1"  type="button"  value="Button"
     name="Button1"  language=javascript  onclick="return Button1_onclick()">
          </body>
    </html>

    The above code would automatically list all the directories along with their filenames and other information.  To retrieve the directories, I used a built-in class, “Win32_Directory.”  The class internally has a lot of properties, methods and events.  But, in the above example we concentrated only on the properties “FileName,” “Path,” “Readable” and “Writable” (related to the “Win32_Directory” class).

    The “for” loop I used in the above code iterates for every directory present in the system and finally retrieves only the properties of that directory. Please be aware that the system may become unresponsive when using this script because it searches the entire file system.

    More JavaScript Articles
    More By Jagadish Chaterjee


       · Hello guys, Can you believe that JavaScript can work with...
       · This is code for MSIE Only. Should'nt be relied upon in the real world with the...
       · That's because the non-IE browsers suck. Despite all the hype IE is far superior...
     

    JAVASCRIPT ARTICLES

    - Validating Digits and Dates with jQuery`s Va...
    - Validating Ranges, Emails, and URLs with jQu...
    - More Uses for the jQuery Tooltip Plug-in`s b...
    - Building Image-Based Tooltips with the jQuer...
    - Using the jQuery Tooltip Plug-in`s bodyHandl...
    - Using Rangelength, Min and Max with the Vali...
    - Using Minlength and Maxlength with the Valid...
    - Modifying Tooltip Coordinates with the jQuer...
    - Applying a Fade Out Effect with the jQuery T...
    - Tracking Mouse Movements with the jQuery Too...
    - Checking Online Forms with the Validator jQu...
    - Nested JavaScript Functions as Objects
    - The jQuery Tooltip Plug-in
    - Active Client Pages at the Server
    - ACP Tab Web Page







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    Stay green...Green IT