Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
Internet Explorer
Legacy APIs
Hosting and Reuse
MSHTML Reference
IHTMLElement2
 attachEvent method
attachEvent method

[This documentation is preliminary and is subject to change.]

Binds the specified function to an event, so that the function gets called whenever the event fires on the object.

Syntax

VARIANT_BOOL retVal = object.attachEvent(event, pDisp);

Standards information

There are no standards that apply here.

Parameters

event [in]

Type: BSTR

BSTR that specifies any of the standard DHTML Events.

pDisp [in]

Type: IDispatch

Pointer to an IDispatch interface that specifies the function to call when event fires.

Remarks

When event fires on the object, the object's event handler is called before pDisp, the specified function. If you attach multiple functions to the same event on the same object, the functions are called in random order, immediately after the object's event handler is called.

The IHTMLElement2::attachEvent method enables a behavior to handle events that occur on the containing page. This method is not limited, however, to behaviors. You can also define a function on a page that attaches to events fired on the same page.

Behaviors that attach to events using the IHTMLElement2::attachEvent method must explicitly call the IHTMLElement2::detachEvent method to stop receiving notifications from the page when the ondetach event fires.

See also

Reference
IHTMLElement2::detachEvent
Conceptual
Introduction to DHTML Behaviors
Using DHTML Behaviors
Using HTML Components to Implement DHTML Behaviors in Script

 

 

Build date: 3/8/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker