Detach method

Notifies the Dynamic HTML (DHTML) behavior that it is being detached from an element.


HRESULT retVal = object.Detach();


This method has no parameters.

Return value


If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


This method notifies the Dynamic HTML (DHTML) behavior when the document unloads; or when the behavior is removed through a call to IHTMLElement2::removeBehavior, or as a result of a Cascading Style Sheets (CSS) change.

This method is called when the master element of an element behavior is removed from the parent document. Windows Internet Explorer calls this method on a behavior when a document is unloaded.

The IElementBehavior::Detach method should not be called from an element behavior, in an attempt to detach the behavior from its master element.

This method is not called if a pointer to the master element that is used by the behavior has been cached.