htc files: Why not to use them?

2019-05-07 04:44发布

问题:

I am developing a web application that aims to give a desktop feeling for the end user. That means I need a cross-browser feeling to the application (who doesn't? eheh).

So, I found about .htc files, for working around some IE tweaks (doesn't support border-radius yet, for example). My doubt is: Why isn't everyone using them? Does it come with some problems I am ignoring? From the place I am seeing, it appears to be almost the holy grail for the front-end programmers...

回答1:

Quoting Wikipedia:

HTML Components (HTCs) are a nonstandard mechanism to implement components in script as Dynamic HTML (DHTML) "behaviors"[1] in the Microsoft Internet Explorer web browser. Such files typically use an .htc extension.

An HTC is typically an HTML file (with JScript / VBScript) and a set of elements that define the component. This helps to organize behavior encapsulated script modules that can be attached to parts of a Webpage DOM.

In two paragraphs, the following are mentioned:

  • Internet Explorer
  • JScript
  • VBScript
  • nonstandard

I think it's obvious why not everybody is using this technology.



回答2:

How to use border-radius.htc with IE to make rounded corners

The server has to server the HTC with the correct MIME type (text/x-component)

That alone is enough to stop JavaScript frameworks such as jQuery or MooTools from being able to use them. The dependency on configuring anything a server in order to get client-side functionality working is beyond unacceptable.

It's a real pity though, htc files really are capable of a lot of interesting things.