3

As the title says, how can i know if the gecko browser completed loading a web page? I know there is document_completed event. But it will get triggered for every time a web page loads. Are there any other ways to check if the current webpage is completed loading.

NistharKPC
  • 83
  • 1
  • 8

2 Answers2

3

My Solotion in vb.net and GeckoFX v45.0.34.0 you can use this tool convert to c# (http://converter.telerik.com/):

Private vWeb As GeckoWebBrowser = New GeckoWebBrowser
Private Property pageready As Boolean = False

Private Sub WaitForPageLoad()
    AddHandler vWeb.DocumentCompleted, New EventHandler(Of GeckoDocumentCompletedEventArgs)(AddressOf PageWaiter)

    While Not pageready
        Application.DoEvents()
    End While

    pageready = False
End Sub

Private Sub PageWaiter(ByVal sender As Object, ByVal e As GeckoDocumentCompletedEventArgs)
    If vWeb.IsBusy = False Then
        pageready = True
        RemoveHandler vWeb.DocumentCompleted, New EventHandler(Of GeckoDocumentCompletedEventArgs)(AddressOf PageWaiter)
    End If
End Sub

Using:

vWeb.Navigate("https://www.google.com")
WaitForPageLoad()
//Do your Work

Hope this solution to resolve.

Dũng IT
  • 2,751
  • 30
  • 29
0
Do While WebBrowser.IsBusy = True
Application.DoEvents()
Loop

Works for me. After WebBrowser.Navigate you have to wait for some time (I use 1 second) before IsBusy becomes True

Paul
  • 78
  • 6