Fires when a document is completely loaded and initialized.
void DocumentComplete( IDispatch *pDisp, VARIANT *URL );
- [in] A pointer to the IDispatch interface of the window or frame in which the document is loaded. This IDispatch interface can be queried for the IWebBrowser2 interface.
- [in] A pointer to a VARIANT structure of type VT_BSTR that specifies the URL, Universal Naming Convention (UNC) file name, or a pointer to an item identifier list (PIDL) of the loaded document.
No return value.
The DISPID for this event is defined in exdispid.h. Use this value to identify the event handler when implementing IDispatch::Invoke.
The value of the URL parameter might not match the URL that was originally given to the WebBrowser Control, because the URL might be converted to a qualified form. For example, if an application specified a URL of www.microsoft.com in a call to the IWebBrowser2::Navigate method or the IWebBrowser2::Navigate2 method, then the URL passed into DWebBrowserEvents2::DocumentComplete is http://www.microsoft.com/. If the server has redirected the browser to a different URL, the redirected URL is passed into the URL parameter.
The WebBrowser Control fires the DWebBrowserEvents2::DocumentComplete event when the document has completely loaded, and the READYSTATE property has changed to READYSTATE_COMPLETE. Following are some important points about the firing of this event.
- In pages with no frames, this event fires one time after loading is complete.
- In pages where multiple frames are loaded, this event fires for each frame where the DWebBrowserEvents2::DownloadBegin event has fired.
- This event pDisp parameter is the same as the IDispatch interface pointer of the frame in which this event fires.
- In the loading process, the highest level frame, which is not necessarily the top-level frame, fires the final DWebBrowserEvents2::DocumentComplete event. At this time, the pDisp parameter is the same as the IDispatch interface pointer of the highest level frame.
For specific code examples using Microsoft Visual Basic and Microsoft Foundation Classes (MFC), see Knowledge Base article Q180366.
Currently, the DWebBrowserEvents2::DocumentComplete does not fire when the IWebBrowser2::Visible property of the WebBrowser Control is set to false. For more information, see Knowledge Base Article Q259935.