Click to return to the Component Development home page    
COMPONENT Element     METHOD Element     HTC Reference    
Web Workshop  |  Component Development

EVENT Element


Defines an event of the HTML Component (HTC) to be exposed to the containing document.

Syntax

<PUBLIC:EVENT
    NAME = sName
    ID = sEventID
/>

Attributes

NAME
Required. String that specifies the name of the event exposed to the containing document.
ID
Optional. String that uniquely identifies the EVENT element within the component. This attribute is analogous to the ID attribute in Dynamic HTML (DHTML).

Methods

eventID.fire([oEvent])
Fires the event to the containing document. This method has an optional oEvent parameter that specifies the event object containing context information.

Element Information

Number of occurrences Any number
Parent elements COMPONENT
Child elements None
Requires closing tag No

Remarks

By specifying a NAME attribute similar to a standard event already defined for the element, a behavior can override the element's default behavior.

Events defined for a behavior do not bubble; they only fire on the element to which the behavior is attached.

Example

This example is derived from a calculator behavior sample. Whenever the result changes, the HTC fires a custom onResultChange event back to the page, passing the result as a custom property of the event object.

Sample Code

<PUBLIC:EVENT NAME="onResultChange" ID="rcID" />

<SCRIPT LANGUAGE="JScript">
function doCalc()
{
   :
   oEvent = createEventObject();
   oEvent.result = sResult;
   rcID.fire (oEvent);
}
<SCRIPT>

This example shows what the containing page looks like.

<HTML XMLNS:InetSDK>
<HEAD>
<STYLE>
@media all {
   InetSDK\:CALC    {behavior:url(engine.htc)} 
}   
</STYLE>
</HEAD>

<InetSDK:CALC id="myCalc" onResultChange="resultWindow.innerText=
    window.event.result">
<TABLE>
<TR><DIV ID="resultWindow" STYLE="border: '.025cm solid gray'"
    ALIGN=RIGHT>0.</DIV></TR>
<TR><TD><INPUT TYPE=BUTTON VALUE=" 7 "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" 8 "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" 9 "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" / "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" C "></TD>
</TR>
<TR><TD><INPUT TYPE=BUTTON VALUE=" 4 "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" 5 "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" 6 "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" * "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" % " DISABLED></TD>
</TR>
<TR><TD><INPUT TYPE=BUTTON VALUE=" 1 "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" 2 "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" 3 "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" - "></TD>
    <TD><INPUT TYPE=BUTTON VALUE="1/x" DISABLED></TD>
</TR>
<TR><TD><INPUT TYPE=BUTTON VALUE=" 0 "></TD>
    <TD><INPUT TYPE=BUTTON VALUE="+/-"></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" . "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" + "></TD>
    <TD><INPUT TYPE=BUTTON VALUE=" = "></TD>
</TR>

</TABLE>
</InetSDK:CALC>
</HTML>
This feature requires Microsoft® Internet Explorer 5 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

See Also

DHTML Behaviors, Implementing DHTML Behaviors in Script, METHOD, PROPERTY


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.