Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is difference between .htc and .js file?

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?

like image 645
Jitendra Vyas Avatar asked Oct 24 '09 11:10

Jitendra Vyas


People also ask

What is .HTC file?

A file with the HTC file extension is an HTML Component file. They're really just HTML files that contain scripts or Microsoft-defined programming code that helps Internet Explorer (some versions, anyway) properly display newer techniques that other, more standards-compliant browsers natively support.

What is a .JS file used for?

What is a JS file? JS (JavaScript) are files that contain JavaScript code for execution on web pages. JavaScript files are stored with the . js extension.

What are JS files called?

There is no official, universal, convention for naming JavaScript files. There are some various options: scriptName. js.

What type of file has a .JS extension?

JavaScript files have the file extension .js.


2 Answers

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.

like image 114
luvieere Avatar answered Sep 29 '22 03:09

luvieere


A htc-file is a behaviour-file, have a look at MSDN🕗, W3C🕗 and here🕗. In a htc-file you can embed HTML-Code as well as Script-Code. Since a htc-file is not a pure Javascript-File, you cannot just convert it, but you may extract the Javascript-Parts of it, if you need.

Most HTC-Files I have seen so far are there to fix Internet Explorer problems, e.g. PNG transparency, which shows the sense of the htc-files: They can attach foreign properties to HTML-Elements, in this case, transparency.

like image 35
schneck Avatar answered Sep 29 '22 01:09

schneck