This topic documents a feature of Binary Behaviors, which are obsolete as of Internet Explorer 10.
Notifies the Dynamic HTML (DHTML) behavior that it has been instantiated.
HRESULT Init( IElementBehaviorSite *pBehaviorSite );
- [in] A pPointer to the IElementBehaviorSite interface through which the DHTML behavior communicates with MSHTML.
Returns S_OK if successful, or an error value otherwise.
This method is the first notification received by the DHTML behavior after it is instantiated by MSHTML, through a call to the IElementBehaviorFactory::FindBehavior method. Any initialization that is required for the DHTML behavior can be done at this point.
You can query the IElementBehaviorSite interface that is passed to the IElementBehavior::Init method for the IElementBehaviorSiteOM interface, the IElementBehaviorSiteCategory interface, the IBindHost interface, and the IServiceProvider interface.
Use the IElementBehaviorSite::GetElement method to get a pointer to the element that the DHTML behavior is attached to. Note that the pointer returned by a call to the IElementBehaviorSite::GetElement method should not be cached, because caching prevents the behavior from receiving a detach call.
The IElementBehavior::Init method is analogous to running an inline script during the parsing phase of a behavior that uses an HTML Component (HTC) file. Do not use IElementBehavior::Init to implement code that references, creates, or modifies content in the primary document. Instead, use the IElementBehavior::Notify method to detect the oncontentready event and the ondocumentready event, which provide notification on the successful parsing of the element that the behavior is attached to, and the primary document, respectively.
MSHTML calls the IElementBehavior::Notify method to indicate when the element and document to which the DHTML behavior is attached are fully parsed. If the DHTML behavior must be downloaded, the contents of the document might be parsed before the IElementBehavior::Init method is called, and the IElementBehavior::Notify method is not called.