The Wonderful World of Web Applications: HTML Apps (HTA) / Page 2 | WebReference

The Wonderful World of Web Applications: HTML Apps (HTA) / Page 2


The Wonderful World of Web Applications: HTML Apps (HTA) [con't]

You can access all of the attributes of the <HTA:APPLICATION> tag via its ID:

Figure 2


Adding Functionality

The purpose of an HTA is to perform event-driven tasks that cannot be accomplished in a regular HTML document or WSH script. To illustrate, we'll create a dropdown list that is populated from a file that resides on the client's hard drive.

In the HTA Helpomatic, select the "On-the-fly listbox" item from the "HTA Elements" list. This selection does not create any HTML markup, but rather, produces Subroutine Code. Click the "Copy to Clipboard" button beside the "Subroutine Code" textarea and paste it within the VBScript tags of the HTA source. By default, the subroutine loads a text file named computers.txt from the same directory as the HTA file and loads the contents into a <SELECT> element named AvailableComputers. From there, you can to tweak the code to suit your particular needs. Here is the same routine with code to dynamically create the <SELECT> element, populate it with the contents of the "trees.txt" file, and append it to the document:

I also incorporated two VB best practices of including the Option Explicit statement to enforce variable declaration and releasing the objects from memory once we're done with them.

Here's the tree list to put in the trees.txt file. Paste them in a text editor and save the file to the same directory as the HTA file:

The above code appends the <SELECT> element directly below the attributes that we printed earlier:

Figure 3

In today's tutorial, we saw how HTAs permit web developers to parlay their scripting and design skills to build desktop applications. Moreover, we affirmed that developers don't need to purchase any specialized software to create them. Next time, we'll explore some security considerations, deployment options, and develop somewhat more abstruse tasks.

Rob Gravelle combined his love of programming and music to become a software guru and accomplished guitar player. He created systems that are used by Canada Border Services, CSIS and other Intelligence-related organizations. As a software consultant, Rob has developed Web applications for many businesses and recently created a MooTools version of PHPFreechat for ViziMetrics. Musically, Rob recently embarked on a solo music career, after playing with Ivory Knight since 2000. That band was rated as one Canada's top bands by Brave Words magazine (issue #92) and released two CDs. In 2007, Rob recorded the KNIGHTFALL CD in collaboration with the former Ivory Knight vocalist and legendary guitarist/producer, Jeff Waters of Annihilator fame. A completely FREE high quality MP3 download of his "Ultraviolence" intrumental, is availalable from his website, Rob is available for short-term software projects and recording session work. to inquire, but note that, due to the volume of emails received, he cannot respond to every email. Potential jobs and praise receive highest priority!

Original: September 30, 2009