« First Post! And a word on XML namespaces
» We’re moving!


HTML Applications

Calvin Allen | 09.05.07 | HTML / CSS, JavaScript, Programming
html-applications

As my first post here on TehDevs, I would like to welcome everyone to the site. Adam and I hope you enjoy reading about our experiences (and hopefully learning something along the way).

Now then, down to business.

I am going to go over some of the basic things I have learned recently about using an HTML application to launch an install from a CD/DVD.

Basically, the HTML app is used when the CD/DVD is run, instead of the normal executable file.

The following example will show you how to create a splash screen for your install, which will run the executable file after 3 seconds.

The file starts out like a normal HTML document, as shown:

The next bit of code in the file sets the characteristics of the application. Such things as Border, Scrolling, etc are defined here. Note that this portion of code is still inside the <head> element

The next part of the code is all javascript, defining the position of the window, what file to run after the splash screen is complete, etc.

The main thing to point out here is the function nextScreen(). This function gets fired when the onLoad even of the body is triggered, which we will see in the next segment of code. Before we can launch any type of file from this html application, we have to declare a new ActiveXObject and assign it to some variable (for this example, we use oShell). Whatever variable you declare for this will then launch your install executable via the Run(“filename”) method. Note this assumes autorun.exe is in the SAME directory as the html app itself. self.close() is to close the html application after the autorun.exe has begun execution.

The final bit of code for this app is the <body> tag:

As the code reveals, when the body has loaded, set a timeout on the window, which calls the nextScreen() function defined in our javascript, that occurs after 5000 milliseconds (5 seconds). We assign a background image to the body like normal HTML and give it a style.

After you have all the code together in a file, save it with a file extension of HTA. For learning purposes, let’s assume we named ours tehdevs.HTA. Now when we create out autorun.inf file for our disc, instead of using the ‘OPEN=tehdevs.HTA’ command to launch the file, we have to use ‘SHELLEXECUTE=tehdevs.HTA’

That’s all there is to it. Burn all said files to a disc, insert into drive, and watch the magic begin (assuming you have autorun enabled, otherwise d-click your drive to launch).

Example Files:
autorun.inf
tehdevs.hta
splash.gif

8 Comments

:

:


« First Post! And a word on XML namespaces
» We’re moving!