Windows Script Components  

createEventObject Method

Creates a DHTML event object to be used in passing event context information to the containing document when the fireEventmethod is called.

oEvent = behavior.createEventObject()

Values

behavior
The ID of the <implements> element used to implement the Behavior interface.
Note   By default, the createEventObject method has global scope and can be accessed without referencing the Behavior handler ID. For example, instead of using Behavior.createEventObject as shown in the syntax, you can simply call the function as createEventObject. For more details, see the <implements> element.
oEvent
An event object created by the method.

Remarks

The same event object cannot be reused in multiple fireEvent calls.

Example

The following partial script component is derived from a hypothetical calculator script component. Whenever the result changes, the script component fires a custom onResultChange event back to the page, passing the result as an expando property of the event object.

Note   A CDATA section is required to make the script in the <script> element opaque. For details, see Script Component Files and XML Conformance.
<component>
<implements type="Behavior">
   <event name="onResultChange"/>
</implements>

<script language="JScript">
<![CDATA[
attachEvent("onclick", doCalc);

function doCalc()
{ 
   // Code here to perform calculation. Results are placed into
   // the variable sResult.
   oEvent = createEventObject();
   oEvent.result = sResult;
   fireEvent("onResultChange",oEvent);
}
]]>
</script>
</component>

The following shows what the containing DHTML page might look like. When the onResultChange event fires, the results of the calculation are extracted from expando property result of the DHTML window.event object and displayed in the resultWindow <DIV> element.

<HTML>
<HEAD>
<xml:namespace prefix="LK" />
<style>
   LK\:CALC {behavior:url(engine.wsc)}
</style>
<script language="JScript">
function showResults(){
   resultWindow.innerText=window.event.result;
}
</script>
</HEAD>

<LK:CALC id="myCalc" onResultChange="showResults()">
<TABLE>
<TR>
   <DIV ID=resultWindow 
      STYLE="border: '.025cm solid gray'" 
         ALIGN=RIGHT>0.</DIV>
</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>
</LK:CALC>
</HTML>

See Also

Exposing Custom Events in Behavior Script Components