HTML Applications

People who know me well regard me as a bit of a Linux geek I have several computers running Linux, two of them servers.

I don't willingly acquire Windows licences, but sometimes they come with computers I buy, mostly second hand. On my desk, I have three desktop computers that came with Windows XP Professional stickers attached, and in some cases, with install media.

Besides that, there are some things I want to do on Linux where I don't have a satisfactory solution. Since I have the licences and the install media, I have some computers with Windows installed. Mostly, they run Linux anyway, but on one system Linux has proven a dead loss.

And then there's the fact that I am employed, in part, to take care of a brace of student computers and those run Windows XP Professional and are managed by another system, running Windows 2003 Server.

A time or two when researching various matters of interest, I've come across mention o HTML Applications, also known as HTAs.

In researching HTAs on Linux, I've seen mentions of "I asked Apple to introduce HTAs to OS X", and another discussion of HTAs on Linux.

In both cases, opponents said, "Can't you do that in XUL?" and then discussion wandered from the real question.

In one case, someone said that it's proprietary and non-standard.

It seemed to me that in both cases, the proponent didn't put the case very well.

Here is my take on it.
Basically, an HTA is a bunch of HTML, with scripts. Download this page, save it as "fred.hta" and you have an HTML application. Not a very useful one perhaps, but it makes a useful point: if you can write HTML you have one of the skills needed to write an HTML application.

The other skill you need is to be able to write scripts. Since HTAs only work on Windows, VBScript is a candidate. It works fine, I used it for my first HTA and I plan on attaching it to this document soonish.

Another obvious candidate is Jscript aka Javascript aka ECMAScript.

Lots of people from the Linux/Unix can write scripts in PERL and/or Python. Those can be used too.

So, to write applications in HTML, the skills you need are the ability to write HTML web pages and scripts in any o several languages. Lots of web developers have those skills.

I know a little HTML, not a lot, and I can write a little PERL (I've written a few thousand lines of code, not a lot). I also used to write a bit of BASIC, so VBScript is slightly familiar. I wrote my little HTA with the aid of a JavaScript book (it describes how to interface to the environment so I can change images being displayed, the text in areas on the screen etc), and a little googling looking for vbscript and other words of immediate interest.

I have previously written some GUI code for OS/2 using IBM's VisualAge for C, some in Java using AWT, read a little about GUI programming using KDE/QT, and I had a very quick look indeed at PHP-GTK.

In my view HTA is the easiest. It might not be the best for everything, or even for anything, but it's sufficient for lots.

Unlike with traditional HTML, HTA code is not served by a remote system. It is not run in some protected sandbox with tightly managed security controls. Like other programs such as Microsoft Word, it runs with the credentials and privileges of the user on the user's computer. A reason I chose to code the HTA scripts in VBScript is that I know VBScript has access to the user's filesystem, exactly the same as any other program the user might run. It could manipulate files in "My Documents."

It might be possible to do some of the same things using XUL, I've not explored the possibility. However, I suspect that since it runs inside Firefox or one of the related browsers, maybe not. And since Firefox here often uses upwards of a gigabyte of RAM without me adding to it, I'm not going to explore that path.

For a competent C or C++ programmer with a good knowledge of Firefox or Konqueror internals, or an interest in acquiring that knowledge, it should be an interesting but not too difficult project to implement HTAs for the rest of us.

It doesn't matter about "proprietary," SMB is proprietary but that didn't prevent its being reverse engineered. It doesn't matter about VBScript, any of the scripting languages commonly used in the Unix/Linux world will do as well.

What I think is needed is a program that is associated with filenames ending .hta in the same way .class is associated with Java. The program has to be able to hook into an existing HTML parser/interpreter. The program must not apply any of the security rules applicable to code loaded from remote sites, this is a users' own program just like Abiword. It must be able to read any file the user can, write and create any files the user can. If variables are shared between scripts that are loaded separately (I've not checked that, don't even know if it's ordinarily the case in HTML documents), then that must be so too.

ps To try out my HTA, you need to be running Windows 2000 or later. Download the file test.txt, examine it, rename it to test.hta then run it:
Start/All Programs/Accessories/Command prompt
CD to move to the directory you stored the file