IE9 and HTC files

Source: Release Notes

HTCs / VBScript
HTML Components (HTC) and VBScript code when used inside of an IE9 or IE10 standards mode page are no longer executed in compatibility view.
Consequently, DOM APIs used by the HTC or VBScript code now behave according to the IE standards mode version of the same APIs.

However, the MS HTC documentation has several examples of basic HTC implementation that works on IE9 (eg. Microsoft MouseOver Hilite Sample)

I tried to copy over the exact same example MS used and place all the necessary files on my server (My MouseOver Hilite Sample), but it doesn’t work on IE9.

I tried a simpler version, but it also didn’t work (Testing IE9 HTC).

While viewing the Developer Tools window, all three examples show the same browser mode (IE9) and the same document mode (Quirks).

The only difference I can find is when I have Fiddler2 loaded to log the headers.

Microsoft HTC Example:

My Microsoft HTC Example:

My Simple HTC Example:

As you can see, the HTC file is not even being loaded on the pages on my server, but is on the MS site.

I’ve tried adjusting the security settings via Internet Options in IE9, but no luck. All three examples work in IE8, though…

Have I forgotten something basic like adding a semi-colon somewhere or is it more complex like I need to be facing south by southwest while chanting the Star Wars theme music as I’m about to sacrifice a goat? :confused:

The example page and your page are both loading in quirks mode in IE9.

Try using a strict doctype, rather than transitional.

Going in another direction, this might work instead of relying on an HTC file, but it seems to be a little glitchy in IE9

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
    li:hover {
        color:red;
        font-weight:bold;
    }
</style>
</head>
<body>
    <ul>
        <li>test</li>
        <li>test 2</li>
    </ul>
</body>
</html>

Changing to strict DTD didn’t help, but thanks for the suggestion. :slight_smile:

To clarify, the final goal isn’t just to achieve a hover state on list item elements. I’m working on patching an old independent CMS that was written before FF, Opera, Chrome, etc. had any real market share (yup, really). It relies on some HTC files and they obviously are not working properly on IE9. I’m trying to narrow down the why my simple examples don’t work, but MS’s does.

To add to the confusion, I tried loading the TwinHelix PNG fix and it loaded the HTC file in IE9.

TwinHelix Fiddler2 log:

I noticed it had the Stict DTD and I even tried copying the exact code from <HTML> to </HEAD>, but my own test sites still didn’t load the HTC file.

I can FEEL the error is something so flippin’ small I’ll probably throw up in my hands in disgust and retire from development (for all of 5 minutes; before I get sucked back in).

A minor breakthrough:

I noticed that upon clearing my IE9 cache (and everything else I could clear) Fiddler showed that the HTC files did in fact load for my test pages on the first load only, thus, IE9 does recognize the behavior rule and on my test server it is simply caching the HTC file.

I am, however, back to the original problem as to WHY Microsoft’s test page actually executes the HTC file while my version does not.

The doctype is supposed to be the first line in your HTML docment–even before the <html> tag

Is the file path incorrect?

I’ve just done the same as you and copied the microsoft page and the htc file file and I get the same results as you. The page works in IE8 but fails in IE9 whereas the same microsoft page (html and css) works in both.

I wonder if IE9 needs something extra in the mime type for htc files.

I was just working on something last week were I used css3pie’s HTC file in IE9. It worked fine without any extra code.

I eliminated any differences except the type of server; Apache vs. IIS.

A quick search resulted in this post, added the proper MIME type and voi-freakin’-la it worked.

All of my troubles solved by a single Apache command line.

Damn you Paul - I want the last six hours of my life back 'cause I bet you knew that the instant you read my post! :wink: