HTC programming ideas

xiaoxiao2021-03-06  58

Abstract

Based on the instance, the programming method of HTC (HTML Component) is discussed, and a basic mode of writing scripting components is proposed.

2. Target reader

HTML developers, script developers, system analyst

3. Background knowledge

HTML, DHTML, CSS

4. Introduction

HTC (HTML Component) is translated into HTML components, not a new technology. But it is not a technology. In fact, it is just a script package mechanism built into the IE browser. Since there are very few people discussed, and Microsoft has no technical support, so there is very few people. But HTML has a good feature to make our development work efficiently. And you have it to find that HTC may change your way you have developed in the past.

The definition of MSDN online on HTC is just as follows:

HTML Components (HTCs) provide a mechanism to implement components in script as Dynamic HTML (DHTML) behaviors. Saved with an .htc extension, an HTC is an HTML file that contains script and a set of HTC-specific elements that define the component.

(HTC is a component that is defined by HTML tag, special tag, and script.)

In general, HTC is a component-based script process. Although the introduction of the browser is different, the same SDK specification is followed. Whether it is a script running environment or a DOM document structure. But HTC has extremely high scalability. That is, HTC can introduce advanced custom behavior (Behavior) for our HTML. For example, custom Attribute, Method, or events. This shows that we can use the HTC mechanism to develop a highly characteristic, reusable, scalable component.

5. Example

In order to make the space won't be too big, we imagine an example. One day, your project manager finds you, saying that the customer is not satisfied with the user UI design in our project, because our customers are more aesthetic people, hate the stars of windows style. So you want to design a series of flat, and can change the color of the color with the mouse. You said this is no problem, but it takes a day, it is not enough to surprise your project manager, you explain to your technical level, it is impossible to write a bunch of scripts and CSS Class to HTML, your product must be Reusable, flexiable, and extendable. He agreed. So the next day, you handed him on the following source code:

ButtonStyleFlat.htc:

There is another SAMPLE for reference:

Sample.html:

(See the following text boxes)

ButtonStyleFlat.htc: