HTA

Browser Object

Fed up with browser wars? MSIE v Netscape, AOL LOL, MSIE v Firefox, MSIE v Opera? Who needs a browser? Peace.

You can easily turn a site into an HTA online or offline.

TIG has probably one of the most developed HTA implementations anywhere — due in large part to a notable absence from the Internet of HTA, I HTA (hasten to add) humbly.

How does an HTA browser object work?

You open HTML pages like in a browser. The pages display within an application window. Not just any application window — a HyperText Application (HTA) window.

HTA is like a browser. It allows you to access files on the World Wide Web and other networks. The only difference is that you won’t find buttons. Back and Forward. You might have reached this page looking for an easy method to create HTAs with navigation buttons. You’ve come to the right place. Look no further than at the script sections in the sample code or download the example (11 KB).

What are the requirements?

All versions of Windows support HTA. Include any features you would in a Web page, and more. HTA runs vbscript and javascript, and ActiveX. Starting TIG in an HTA window requires Internet Explorer 5.5. You can run the browser object in two ways. To test-drive my HTA (from www.teanow5pm.co.uk), do this —

Cache Method: “Run” (or open — do not save, then run) index.hta (5.7 KB). (Click on the link.) Your browser caches the file and runs it from the cache. Some browsers only permit you to save the file.

Save Method: Download htas.zip (10 KB). (Click on the link.) The ZIP archive contains four HTAs, a MIDI jukebox (1), an MP3 song (2), a JAVA applet (3) and TIG (4). The MIDI jukebox, the MP3 song and the JAVA applet open (in application windows) when you click on them or open from TIG that has clickable links.

Extract midiload.hta (1), tchaser.hta (2), tssp3.hta (3) and index.hta (4), keeping the files together after extracting them in the same folder. Double-click index.hta to open TIG.

Why don’t more people have HTA sites?

HTA is a means of distributing HTML. That does not endear it to many who mistrust deployable code. Malicious HTAs are coming to get you.

What can you do to protect yourself against naughty HTAs?

Don’t click on files with that extension. Data Execution Prevention (DEP) on Vista might protect you by stopping legacy ActiveX controls from doing mischief inside HTAs.

Can you get an upgrade for the HTA rendering engine?

By default, mshta.exe runs in compatibility view, which displays doctype strict pages in IE7 standards mode and doctype transitional pages in IE5 (quirks) mode. It is however possible to modify (slightly) the default by adding a DWORD (32-bit) value to the Windows registry. The value you set defines IE9 compatibility view. (On Windows 10 and 11 this is now unnecessary.)

    HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER
       SOFTWARE
          Wow6432Node (64 bits)
             Microsoft
                Internet Explorer
                   MAIN
                      FeatureControl
                         FEATURE_BROWSER_EMULATION
                            mshta.exe = (DWORD) 2710 (IE10)
                            or
                            mshta.exe = (DWORD) 2af8 (IE11)

For more information about these settings and possible values read this MSDN article:

http://msdn.microsoft.com/en-us/library/ee330730(VS.85).aspx

When you set the document compatibility to IE9 mode, you are able to switch it on. In HTA files include a meta tag in the HTML head section, near the top.

<meta http-equiv="x-ua-compatible" content="ie=9">

In your HTML pages consider specifying the highest standards mode available, content="IE=edge". It will ensure IE9 functionality is enabled for those pages on newer platforms. If using frames or iframes placing the meta directive in the parent frame should be enough.

A closing comment from me. HTAs are not DPI-aware. You will need to manually scale all of your content for HiDPI displays with CSS – too much work for the wicked – or by zooming in – hit [Ctrl][+] keys until the size is right – what browsers do too.

Links

../hta/index.hta (5.7 KB — TIG)

../hta/midiload.hta (3.6 KB — Midi Jukebox)

../hta/htas.zip* (10 KB)

* Readme included. Peace.