Something I depend on quite frequently is determining when a web page in a WebBrowser control has completely loaded, including all frames. If you’ve ever worked with this control and relied on the DocumentCompleted event, you may have come across the inconsistency with it when dealing with pages that contain HTML frames. The little snippet below does a very good job with detecting completely loaded pages using the VB.Net WebBrowser control, including all HTML frames on the page. Works with AJAX too!
Private Sub WebBrowser1_DocumentCompleted( _
ByVal sender As Object, _
ByVal e As WebBrowserDocumentCompletedEventArgs _
) Handles WebBrowser1.DocumentCompleted
If Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then