Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - HTML Applications: Giving WSH a User Inter...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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? 
WINDOWS SCRIPTING

HTML Applications: Giving WSH a User Interface
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 5
    2008-02-05

    Table of Contents:
  • HTML Applications: Giving WSH a User Interface
  • Creating your first HTA
  • Building the page
  • Taking it one step further

  • 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


    HTML Applications: Giving WSH a User Interface - Creating your first HTA


    (Page 2 of 4 )

     

    Like all other scripts, HTAs are nothing more than simple text files. They use the .hta file extension and can be executed directly. They take the form of an html file. Those of you familiar with browser scripting will find making the transition very easy.

    You’ll be able to take advantage of both the WSH environment as well as the browser DOM. Since HTAs execute in a subset of Internet Explorer, you’ll also be able to do most anything the browser itself can do. That means (among other things) that you have XHTML, HTML, CSS, and JavaScript at your disposal. If you can do it inside your browser, chances are good that you can do it in an HTA as well.

    A basic HTA script looks quite similar to a traditional HTML page. There are two things that I find quite refreshing about HTAs as opposed to web development. In an HTA, you’re always using Internet Explorer. This eliminates a need for cross-browser compatibility. Second, you don’t have to concern yourself with validation.  While I recommend getting used to XHTML’s “table-less” design, you can freely use them in HTAs and no one will ever know the difference.

    <html>

    <head><title>My HTA</title>

    <HTA:APPLICATION ID="oHTA";

      APPLICATIONNAME="Visual Ping";

      BORDER="thin";

      BORDERSTYLE="normal";

      SINGLEINSTANCE="no";

     />

    </head>

    <body>

    </body>

    </html>

    As you can see, an HTA is constructed of simple HTML. The only difference is the inclusion of the HTA:APPLICATION object. The addition of this object is what allows you to use the HTA DOM. You can set its exposed properties in the form of attributes.  For a complete list of attributes, please visit the MSDN HTML Application Reference.

    Notice the inclusion of the ID attribute. This allows us to assign a reference to the HTA:APPLICATION object. You will use this reference later in your script whenever you need to access the properties or methods associated with the HTA DOM.

    This code doesn’t do much at this point. A blank page isn’t very useful. We need to add some HTML.

    We’re going to make an HTA that performs a simple ping operation. It will then return the result back into our window. But before we get too involved, let’s get some simple stuff out of the way.

    More Windows Scripting Articles
    More By Nilpo


     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





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