c# - 如何知道壁虎浏览器是否完成加载网页?

正如标题所说,如何知道gecko浏览器是否完成加载网页? 我知道有 document_completed 事件。但是每次加载网页时都会触发它。 有没有其他方法可以检查当前网页是否加载完成。

最佳答案

My Solotion 在 vb.net 和 GeckoFX v45.0.34.0 中,您可以使用此工具转换为 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

使用:

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

希望这个解决方案能够解决。

https://stackoverflow.com/questions/33116446/

相关文章:

laravel - 如何在 Laravel 的容器中重新绑定(bind)?

session - 身份验证为匿名的用户已尝试访问拥有的 session

elixir - 左外连接与 Elixir 的理解

maven - 在 Nexus 中部署后,POM.xml 中的变量没有被解析?

time - NetLogo 时间扩展 : Plotting graphs does not wor

numpy - numpy 中有 elliptictheta 函数吗?

codeigniter - 从数据库下载文件或在 codeigniter 中保存文件夹

android - 将抽屉导航添加到现有的 Android 谷歌地图

c++11 - 将 char16_t 转换为 long/integer,(相当于 atoi/atol

cmake - 如何编写功能测试脚本在cmake/ctest下运行