Note that the URL in DocumentCompleted may be different from navigating the URL due to server migration or URL normalization (for example, you go to www.microsoft.com and get http://www.microsoft.com in document completed)
On pages without frames, this event fires once after the download is complete. On pages with multiple frames, this event is triggered for each navigation frame (note support is supported inside the frame, for example, clicking on a link in a frame can move frame by frame to another page). The highest-level navigation frame, which may or may not be a top-level browser, fires the final DocumentComplete event.
In the native code, you compare the sender of the DocumentComplete event to determine if the event is the last event in the navigation or not . However, on Windows Forms, the sender parameter does not end with WebBrowserDocumentCompletedEventArgs. You can break your own event to get the parameter value, or check the readystate property in the browser or frame documents in the DocumentCompleted event handler to see if all frames are in a ready state.
There is a test with the readystate method, as if there is a download manager , and navigation is to the download file, navigation can be canceled by the download manager and readistate will not be completed.
Sheng Jiang θ ζ May 6, '10 at 18:59 2010-05-06 18:59
source share