FindBehavior method

Requests that the specified Dynamic HTML (DHTML) behavior be instantiated.


HRESULT retVal = object.FindBehavior(bstrBehavior, bstrBehaviorUrl, pSite, ppBehavior);


  • bstrBehavior [in]
    Type: BSTR

    A string that specifies the name of the requested behavior.

  • bstrBehaviorUrl [in]
    Type: BSTR

    A string that specifies the URL of the requested behavior.

  • pSite [in]
    Type: [IElementBehaviorSite](aa753721(v=vs.85).md)

    A pointer to the host's IElementBehaviorSite interface.

  • ppBehavior [out, retval]
    Type: [IElementBehavior](aa753744(v=vs.85).md)

    A pointer that returns the IElementBehavior interface.

Return value


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


After the Dynamic HTML (DHTML) behavior is instantiated, MSHTML calls the IElementBehavior::Init method.

Specify the case of the bstrBehavior parameter to be all caps when you use this method with element behaviors; for attached behaviors, specify the bstrBehavior parameter in lowercase. Because the bstrBehavior parameter has a specific case based on the type of behavior, you must take precautions when this parameter is used in a string comparison: either the case of the string should be forced, or a case–insensitive comparison should be used.