GetElement method

Gets the element to which a Dynamic HTML (DHTML) behavior is attached.


HRESULT retVal = object.GetElement(ppElement);


  • ppElement [out, retval]
    Type: [IHTMLElement](aa752279(v=vs.85).md)

    A pointer to an IHTMLElement interface that specifies the element to which the Dynamic HTML (DHTML) behavior is attached.

Return value


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


A Dynamic HTML (DHTML) behavior can access the host Dynamic HTML (DHTML) Object Model through the element that is retrieved by this method.

This method can be successfully called after the Dynamic HTML (DHTML) behavior has received the BEHAVIOREVENT_CONTENTREADY notification through a call to the IElementBehavior::Notify method.

This method returns a pointer to the master element of a behavior. Do not cache the pointer returned by this method. During the IElementBehavior::Init call, cache a pointer to the IElementBehaviorSite interface, and use the GetElement method whenever necessary.

If the ppElement pointer is cached, then Windows Internet Explorer calls AddRef to increment the reference count on the behavior. This practice can cause memory leaks when the behavior is shut down, because references to the behavior remain.