Simple HTC tutorial

Source: Internet
Author: User

According to Microsoft (r) Internet Explorer 5, HTML components (htcs) provide a mechanism to use scripts as dynamic HTML (DHTML) behavior to implement component functions. Save as the. HTC extension. An HTC is an HTML file containing scripts and a group of HTC special elements used to define components. This part contains related elements and their supported members.

Object
DocumentDisplays HTML documents in a given browser window.
ElementReturns a reference for the connection behavior label in the main document.
Public: attachBinds a function to an event. Therefore, the function is called every time an event occurs on a special object.
Public: ComponentSpecify the content of the file with HTC.
Public: DefaultsSet the default attributes of HTC.
Public: EventDefine an HTC event to expose it to documents containing the HTC.
Public: MethodDefine an HTC method to expose it to documents containing the HTC.
Public: PropertyDefine an HTC attribute to expose it to documents containing the HTC.

 

Method
Createeventobject
Create an event object, which is used when you need to pass the event additional information to the fire method of the public: Event element.

Event
Oncontentready
It occurs when the content of the element connected to the behavior is completely parsed.
Oncontentsave
The content of an element that is connected to an element action is saved or copied.
Ondetach
A behavior occurs before a connection is removed from an element.
Ondocumentready
This occurs when the document containing the action is completely parsed.

Public: property element
Bytes --------------------------------------------------------------------------------------
Define an HTC attribute to expose it to documents containing the HTC.

Format
<Public: Property
Get = "sgetfunction"
Id = "spropertyid"
Internalname = "sinternalname"
Name = "sname"
Persist = "bpersist"
Put = "sputfunction"
Value = "vvalue"
/>

Attribute
Get
Optional. The string of the function called when the specified property value is obtained. A public: property element that only specifies the get attribute but does not specify the put attribute is a read-only attribute.
ID
Optional. Public in the component: the unique identifier string of the property element. This attribute is similar to the ID attribute in DHTML.
Internalname
Optional. A string that contains the name of the method submitted in the document. The internal name must be widely correlated before any reference in the component; otherwise, a script error occurs, indicating that the name is undefined. If no internal name is specified, the name attribute is used by default.
Name
Required. Specifies the string that is exposed to the name of the attribute containing the document. By default, the name attribute is also used to submit attributes in the component, unless the internalname attribute is specified.
Persist
Optional. Specifies whether to adhere to the Boolean value of the attribute as the leaf area.
Put
Optional. Specifies the string of the function called when the property value is set. A public: property element with the get and put attributes specified is a read/write attribute. If a put function is specified and the get function fails to be specified, this attribute can only be writable. In general, this is not expected.
Value
Optional. Specifies the variable of the default attribute value.

Method
Propertyid. firechange ()
Indicates that the attribute value of a document is changed when the onpropertychange event occurs on the element. If the put attribute is not specified, onpropertychange automatically occurs when the attribute in the include document is set.

Element Information
Parent element: public: Component
Child element: None

Remarks
When the specified name attribute is the same as the name of a standard method that has been defined for the element, a behavior can reload the default behavior of the element.
If the put or get attribute is specified, the internalname attribute is ignored. You can set and/or obtain the attribute value through the function specified in put and get attributes. The priority is higher than that set through internalname and/or the attribute value is obtained.
For a function specified by the put property, you must note that the firechange method of the public: property element is used to change the attribute value. By calling this method, the onpropertychange event occurs in the corresponding elements of the document, and the propertyname of the event object is set to the attribute name.

Public: MethodElement
Bytes --------------------------------------------------------------------------------------
Define an HTC method to expose it to documents containing the HTC.

Format
<Public: Method
Id = "Sid"
Internalname = "sinternalname"
Name = "sname"
/>

Attribute
ID
Optional. Public in the component: the unique recognition string of the method element. This attribute is similar to the ID attribute in DHTML.
Internalname
Optional. A string that contains the name of the method submitted in the document. By default, name also specifies the method submitted to the component, unless the internalname attribute is specified.

Element Information
Parent Element
Public: Component
Child Element
None
Minimum running environment
Remarks
When the specified name attribute is the same as the name of a standard method that has been defined for the element, a behavior can reload the default behavior of the element.

 

Public: Event Element
Bytes --------------------------------------------------------------------------------------
Define an HTC event to expose it to documents containing the HTC.

Format
<Public: Event
Id = "seventid"
Name = "sname"
/>

Attribute
ID
Optional. Public in the component: the unique recognition string of the event element. This attribute is similar to the ID attribute in DHTML.
Name
Required. String that specifies the name of the event submitted in the main document.

Method
Eventid. Fire ([oevent])
Contains document events.
This method has the following parameters:
Oevent
The object that specifies the additional information contained in the event object.

Element Information
Parent Element
Public: Component
Child Element
None
Remarks
By specifying a name attribute, similar to a standard event that has been defined for an element, a behavior can overload the default behavior of the element.
Action-defined events do not bubble. They only occur on the elements that are connected to the behavior.

 

Public: DefaultsElement
Bytes --------------------------------------------------------------------------------------
Set the default attributes of HTC.

Format
<Public: Defaults
Canhavehtml = "bcanhavehtml"
Contenteditable = "beditable"
Style = "sstyle"
Tabstop = "bistabstop"
Viewinheritstyle = "binheritsstyle"
Viewlinkcontent = "bviewlinkcontent"
Viewmastertab = "bviewmastertab"
/>

Attribute
Canhavehtml
Optional. It is a Boolean value of one of the following.
False
The tag content defined in the HTC file cannot contain HTML tags.
True
The tag content defined in the HTC file can contain HTML tags.
Contenteditable
Optional. It is a Boolean value of one of the following.
Inherit
Default value. The object inherits the capability of being edited by users from its parent level.
False
The tag content defined by the HTC file cannot be edited.
True
You can edit the TAG content defined in the HTC file.
Style
Optional. Specifies the style string of the tag defined by the HTC file.
Tabstop
Optional. It is a Boolean value of one of the following.
False
Default value. The tag defined by the HTC file cannot be activated by the tab.
True
The tag defined by the HTC file can be selected and activated by the tab.
Viewinheritstyle
Optional. It is a Boolean value of one of the following.
False
Viewlink does not inherit styles from the main HTML file.
True
Default value. Viewlink inherits the style from the main HTML file.
Viewlinkcontent
Optional. It is a Boolean value of one of the following.
False
Default value. Tags in HTC documents are not used as viewlink.
True
The tag in the HTC file is used as viewlink.
Viewmastertab
Optional. It is a Boolean value of one of the following.
False
The main element of viewlink is not included in the tab sequence of the main document.
True
Default value. The main element of viewlink is included in the tab sequence of the main document.

 

Element Information
Parent Element
Public: Component
Child Element
None

Public: ComponentElement
Bytes --------------------------------------------------------------------------------------
Specify the content of the file with HTC.

New Content in Microsoft Internet Explorer 6
The literalcontent attribute supports nesting as a new possible value, and creates a nested text content element behavior.

Format
<Public: Component
Id = "Sid"
Lightweight = "blight"
Literalcontent = "sliteral"
Name = "sname"
Supportseditmode = "beditable"
Tagname = "stagname"
Urn = "surn"
>
<! -- Sub-Level element -->
</Public: component>

Attribute
ID
Optional. Public in the component: the unique character string recognized by the component element. This attribute is similar to the ID attribute in DHTML.
Lightweight
Optional. Specifies whether the HTC file contains a tag string. If the HTC file does not contain tags, set this attribute to true to improve performance. This attribute is valid for any HTC file.
True
The HTC file does not contain tags, so you do not need to parse and present custom tags each time. These tags are defined by the HTC file and used in the main document.
False
Default value. HTC contains custom tags that must be parsed and displayed. These tags are defined by the HTC file and used in the main document.
Literalcontent
Optional. Specifies whether the content contained in the custom tag is parsed and displayed, or as a string processed by the data island. This attribute is valid only when the HTC file defines an element action. You need to use the tagname attribute. For more information, see remarks.
False
Default value. The text and tags defined by the tagname attribute are parsed and displayed as data islands.
Nested
Internet Explorer 6 and later versions. Content within the first opening and last closing of the tag defined by the tagname attribute is treated as a data is lan d and is not parsed or rendered. For more information, see use the literalcontent attribute.
True
Content within the first opening and last closing of the tag defined by the tagname attribute is treated as a data is lan d and is not parsed or rendered.
Name
Optional. String that specifies the name of the behavior submitted in the main document.
Supporteditmode
Optional. Specifies whether the content of an HTC file can be edited. This attribute is valid only when the HTC file defines an element action.
True
The tags in the HTC file can be edited.
False
Default value. Tags contained in HTC files cannot be edited. You can set the iscontenteditable attribute to variant_true for each element in the HTC file to overload this attribute value.
Tagname
Optional. A string that specifies the custom tag name. The tag is defined by the HTC file and imported to the main document. This attribute is valid only when the HTC file defines an element action. For more information, see remarks.
Urn
Optional. String, in the unified Resource Name (URN) format, to uniquely identify this component. Therefore, it can be uniquely identified when multiple actions occur in the same name event. When an event occurs, the srcurn attribute of the event object is set to urn where the event is upstream.

 

Element Information
Child Element
At most once
Public: Defaults
Appears one or more times
Public: attach, public: event, public: method, public: Property
Remarks
Public: The component element can define two completely different types of behavior. One is join behavior. You can use the behavior Cascading Style Sheet (CSS) attribute to modify the behavior of an existing element. The second type is described in Internet Explorer 5.5, which is called an element action. An element behavior is used to define custom tags used in webpages like standard HTML tags.
An element action means the creation and use of a custom tag in a webpage. Therefore, when an HTC file defines an element behavior, it is necessary to define the tagname attribute of the public: component element. As previously pointed out, some attributes of this element are specially designed for element behavior. For more information, see query element behavior.
The name attribute is particularly useful when multiple behaviors are connected to the same element. Because it allows you to call attributes and methods that contain the behaviors required in the document. If multiple behaviors in a document are connected to a <span id = "myspan"> element, you can use the following format to set the delay attribute of the behavior named behaviorabc.
Myspan. behaviorabc. delay= 1000;

Public: attachElement
Bytes --------------------------------------------------------------------------------------
Binds a function to an event. Therefore, the function is called every time an event occurs on a special object.

Format
<Public: attach
Event = "sevent"
For = "sobject"
Id = "Sid"
Onevent = "seventhandler"
/>

 

Attribute
Event
Required. Specifies a dynamic HTML (DHTML) event, or any string of events specified by the HTML component (HtC) listed in the HTC reference.
For
Optional. It is a string in the lower nominal value to identify the event source.
Document
Reference Document Object.
Element
Default value. The element that references the behavior connection.
Window
Reference the window object.
ID
Optional. Public in the component: the unique recognition string of the attach element. This attribute is similar to the ID attribute in DHTML.
Onevent
Required. The direct declaration of the event handler function or a specified string of an in-line script.

Element Information
Parent Element
Public: Component
Child Element
None
Remarks<P>

 

Public: The attach element is a declaration of the attachevent method.
When a specified event is connected to a behavior element, the event processing part of the element is called first before the behavior event is processed. If multiple actions are connected to one element and multiple event processing parts are defined on the same event of the same element, the function will be called randomly after the element event processing part is called.
When providing a value for onevent, do not assign the name of an existing DHTML event to the event processing function. The name of an existing DHTML event may be recursively incorrect.
The event name is case sensitive to all scripting languages.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.