What is the difference between .htc and .js files?

What is the difference between .htc and .js files? Can we convert any .htc file to a .js file?

The problem is that we use htc to create png fixes, then add htc to the css file using

body { behavior: url("csshover3.htc"); } 

But this is not true for W3C, so you want to convert .htc to .js, and then use js as a file to attach to make it a valid W3C.

Can someone tell me how to convert and use any .htc file as a javascript file?

+46
javascript html-components
Oct 24 '09 at 11:00 a.m.
source share
3 answers

Technically, you can use conditional comments to allow code verification.

http://msdn.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx

Hacking is hacking, it’s just strange that MS made this hack in such a way that it really hacked.

Now, something else to consider - are you using the JavaScript library? Then you should use the library to perform this function, which eliminates the need to use HTC (which requires JavaScript to run).

+8
Oct 27 '09 at 6:25
source share

From the Microsoft HTC πŸ•— Reference :

In Microsoft Internet Explorer 5 and later, HTML (HTC) components provide a mechanism for implementing components in a script as dynamic HTML (DHTML) behavior. HTC is an HTML file containing a script and a set of HTC-specific elements that define the component. The component is saved with the extension .htc. This section lists these HTC-specific items and the members they support.

Thus, they are not just javascript.js files, they also contain a set of HTC-specific elements.

Edit:

Regarding the conversion from .htc to .js, I'm not sure that this can be done directly, but I came across this set of .js tools to solve the same problems that .htc files are trying to fix in IE.

+39
Oct 24 '09 at 11:08
source share

The htc file is a behavior file, see MSDN πŸ•— W3C πŸ•— and here πŸ•— . In the htc file you can embed HTML code as well as Script-Code. Since the htc file is not pure Javascript file, you cannot just convert it, but you can extract parts of Javascript if you need it.

Most HTC files that I have seen so far exist to solve Internet Explorer problems, for example, PNG transparency, which shows the meaning of htc files: they can attach third-party properties to HTML elements, in this case transparency.

+17
Oct 24 '09 at 11:11
source share



All Articles