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?

Instead of opening a Web page online in your browser, you open the page locally. The page displays within an application window. Not just any application window, that is: a HyperText Application (HTA) window.

If you’re looking to create HTAs with browser navigation buttons, look no further. Have a look at the script sections in the sample code or download the example (11 KB).

What are the requirements?

Starting TIG in an HTA window requires Microsoft Windows and Internet Explorer 5.5. You can run the browser object in two ways. To test-drive my HTA (from this site), do this —

Cache Method: “Run” (or open — do not save, then run) index.hta. (Click on the link.) The browser caches index.hta before it launches. The file is 5.6 KB. 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 are embedded in TIG, to be opened as links. The HTAs launch application windows. Extract midiload.hta (1), tchaser.hta (2), tssp3.hta (3) and index.hta (4). Keep the files together, extracting them to the same place. Double-click index.hta to open TIG in HTA mode.

Why don’t more people have HTA sites?

HTA is a means of distributing HTML pages. 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 an .hta extension. Data Execution Prevention (DEP) on Vista might protect you by stopping legacy ActiveX controls from running inside HTAs.

Can you get an upgrade for the HTA rendering engine?

By default, HTAs run in compatibility view, which displays doctype strict pages in IE7 standards mode and doctype transitional pages in IE5 (quirks) mode. If you have Internet Explorer 10 or 11 installed, you can change the behavior by adding a DWORD (32-bit) value to the Windows registry. This will enable IE9 compatibility view:

    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)

Now that you have defined the default mode, you can switch on IE9 features. Include ‘meta http-equiv="x-ua-compatible" content="IE=9"’ in the HTA header. For more information about these settings and possible values check out MSDN:

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

One final note. HTAs are not DPI-aware. You will need to manually scale all of your HTML content for HiDPI displays using CSS – too much work for some – or by zooming in – hit Ctrl+ until you have the right size – what browsers do too.