Detecting WebBrowser Page is Loaded

Detecting WebBrowser Page is Loaded

Added by Mind Hunter updated on Friday, February 9, 2018

How To Detect Web Browser Control Has Finished Page Loading?:

Sometimes while embedding WebBrowser control in windows form application we want to know the point where control load all its contents.

To tackle this issue, we use DocumentCompleted event but this event fire multiple time during page load so how is it possible to detect page loading is completed.

The answer is still use DocumentCompleted event but with different way. If we check WebBrowserReadyState when this event fire, we can easily achieve our goal.


This enumeration is used by the WebBrowser.ReadyState property to indicate the current state of the WebBrowser control.WebBrowserReadyState has following states

  • Uninitialized - No document is currently loaded.
  • Loading - The control is loading a new document.
  • Loaded - The control has loaded and initialized the new document, but has not yet received all the document data.
  • Interactive - The control has loaded enough of the document to allow limited user interaction, such as clicking hyperlinks that have been displayed.
  • Complete - The control has finished loading the new document and all its contents.

WebBrowserReadyState.Complete is the key to check page load complete or not. Use it as follows

DocumentCompleted += webBrowser1_DocumentCompleted;				
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    if (this.webBrowser1.ReadyState == WebBrowserReadyState.Complete)        
    	//On page loading completion do action


32 Tutorials
27 Snippets
6 Products


Contact Us

Contact us

Stay Connected