Detect WebBrowser complete page loading

Neir0 picture Neir0 · May 6, 2010 · Viewed 117.8k times · Source

How can I detect when a System.Windows.Forms.WebBrowser control has completed loading?

I tried to use the Navigate and DocumentCompleted events but both of them were raised a few times during document loading!

Answer

Paul Kearney - pk picture Paul Kearney - pk · May 6, 2010

I think the DocumentCompleted event will get fired for all child documents that are loaded as well (like JS and CSS, for example). You could look at the WebBrowserDocumentCompletedEventArgs in DocumentCompleted and check the Url property and compare that to the Url of the main page.