What is difference between .htc and .js file?

Jitendra Vyas picture Jitendra Vyas · Oct 24, 2009 · Viewed 42.8k times · Source

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

The problem is if we use htc to make png fixes, then we add htc to css file using

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

But this is not W3C valid, so want to convert the .htc to .js and then use as a js file to attach in so it will be W3C valid.

Can anyone tell me how to convert and use any .htc file as JavaScript file?

Answer

luvieere picture luvieere · Oct 24, 2009

From the Microsoft HTC Reference🕗:

For Microsoft Internet Explorer 5 and later, HTML Components (HTCs) provide a mechanism to implement components in script as Dynamic HTML (DHTML) behaviors. An HTC is an HTML file that contains script and a set of HTC-specific elements that define the component. The component is saved with an .htc extension. This section lists these HTC-specific elements and the members they support.

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

Edit:

Concerning the conversion from .htc to .js, I'm not sure if it can be done directly, but I've come across this set of .js tools to address the same issues that .htc files are trying to fix in IE.