HTML Applications (HTA) are fully-fledged, stand-alone applications. Here are some quick facts about HTAs:
A HTA works on Microsoft Windows operating system (with Internet Explorer 5 or later installed).
A HTA has the .hta extension. Double-clicking a .hta file runs it like any other executable file.
A HTA uses Internet Explorer engine to render your application, buttons, menus, etc.
You design the user interface - HTA does not use Internet Explorer's user interface.
You can install a HTA like any other program.
You have full access to the file system.
Use your knowledge of JavaScript and HTML to create lean, efficient stand-alone programs with a rich user interface and full access to the client system: HTAs. |
Your first HTA
Creating a HTA is simple: your web page becomes a HTML Application when you:
Add the hta:application tag to it, and
Save the page with the .hta extension.
|
The hta:application tag specifies the name, caption, icon, border, and other properties of your application.
The hta:application tag has lots of properties, but there is no need to memorize them, JavaScript Editor, does it for you. To create a HTA file using the HTA template:
Start a new document, type hta and press Ctrl+Space, and
Fill in the properties, and press OK.
JavaScript Editor generates the code for you, depending on selected options:
<html> <head> <title></title>
<hta:application
id="MyApp"
applicationName="My Application"
border="thick"
borderStyle="sunken"
caption="yes"
contextMenu="yes"
icon=""
innerBorder="yes"
maximizeButton="yes"
minimizeButton="yes"
navigable="no"
scroll="yes"
scrollFlat="no"
selection="yes"
showInTaskBar="yes"
singleInstance="no"
sysMenu="yes"
version="1.0"
windowState="normal"
>
</head>
<body>
</body>
</html>
|
Save the file as MyApp.hta
To run your HTA, click on the Launch / View in Browser button (alternatively, double-click MyApp.hta to launch it).
Your application runs, but the client area is blank - there is nothing to display. In the example below we added JavaScript code to display all the properties of your application:
<html> <head>
<title>My application</title>
<hta:application
id="MyApp"
applicationName="My application"
border="thick"
borderStyle="normal"
caption="yes"
contextMenu="yes"
icon=""
innerBorder="yes"
maximizeButton="yes"
minimizeButton="yes"
navigable="no"
scroll="yes"
scrollFlat="no"
selection="yes"
showInTaskBar="yes"
singleInstance="no"
sysMenu="yes"
version="1.0"
windowState="normal"
>
</head>
<body>
This application has the following properties:<br><br>
<script language = JavaScript>
<!--
document.write("Name: " + MyApp.applicationName + "<br>");
document.write("Border: " + MyApp.border + "<br>");
document.write("Border style: " + MyApp.borderStyle + "<br>");
document.write("Caption: " + MyApp.caption + "<br>");
document.write("Context menu: " + MyApp.contextMenu + "<br>");
document.write("Command line: " + MyApp.commandLine + "<br>");
document.write("Icon: " + MyApp.icon + "<br>");
document.write("Inner border: " + MyApp.innerBorder + "<br>");
document.write("Maximize button: " + MyApp.maximizeButton + "<br>");
document.write("Minimize button: " + MyApp.minimizeButton + "<br>");
document.write("Navigable: " + MyApp.navigable + "<br>");
document.write("Scroll: " + MyApp.scroll + "<br>");
document.write("Flat scrollbar: " + MyApp.scrollFlat + "<br>");
document.write("Allow selection: " + MyApp.selection + "<br>");
document.write("Show in task bar: " + MyApp.showInTaskBar + "<br>");
document.write("Allow only single instance: " + MyApp.singleInstance + "<br>");
document.write("System menu: " + MyApp.sysMenu + "<br>");
document.write("Version: " + MyApp.version + "<br>");
document.write("Window state: " + MyApp.windowState + "<br>");
//-->
</script>
</body>
</html>
|
Paste the code into a new document and save the file as MyApp2.hta
Click on the Launch / View in Browser button.
Next |