First HTC

xiaoxiao2021-03-06  87

HTC is an abbreviation for HTML Component, which is a client component supported by the IE5 and subsequent browsers. According to my personal understanding, HTC is a piece of script that encapsulates client behavior based on DHTML. Each HTC is stored in * .htc file, an HTC is a client "class".

The most important thing to write HTC is to know the meaning of the Element object, which represents the current HTC, similar to this in the C # class. For example, Element.innerHTML can access the HTML code included in the current HTC object in Document. Since HTC is "class", it certainly has attributes, methods, events, and the following brief explanation:

l : Defines HTC, this tag is other defined parent elements.

l : Defines the properties of the HTC, and the three definitions represent the attribute name, read attributes, and set the HTC when the properties is called.

l : Defines the HTC method, and Name defines the method name.

l : Defines HTC events, name defines the event name, ID is an optional attribute, uniquely identifying this event in the HTC.

l : Defines the corresponding method of passing the browser to the HTC event, where Event is an event incorporated by the browser, and Onevent is a way to process the event.

Common HTC definitions are so much, for more detailed information, please refer to

Http://msdn.microsoft.com/librar ... Eference / htcref.asp, English d, 嘿.

We often see such an effect on some webpages: Users click on a button, text display, click this button again, the text disappears, but the browser does not refresh. Below I use HTC to achieve this simple effect. The programming idea is like this: uses HTC to simulate a switch, it has two states "on" and "OFF" (readable / write attribute status); users can set the text displayed in both states (setting attribute turnofftext And TurnonText); When the user clicks the switch, the switch status is reversed and triggered an event (onStatusChanged) to inform the user, and the user can write the code to respond to this event; the HTC also defines a method (REVERSSTATUS), used to reverse The status of the switch. Here is this HTC code: