我通常会通过 DocumentCompleted 事件了解浏览器是否已完成加载。
但最近,当我尝试像http://youtube.com这样的网站时,documentcompleted 事件不止一次触发。我放置了 console.writeline 来检查发生了什么
Private Sub mybrowser_Navigating(ByVal sender As Object, ByVal e As Gecko.GeckoNavigatingEventArgs) Handles mybrowser.Navigating
Console.WriteLine("navigating " + e.Uri.AbsoluteUri)
End Sub
Private Sub mybrowser_Navigated(ByVal sender As Object, ByVal e As Gecko.GeckoNavigatedEventArgs) Handles mybrowser.Navigated
Console.WriteLine("navigated " + e.Uri.AbsoluteUri)
End Sub
Private Sub mybrowser_DocumentCompleted(ByVal sender As Object, ByVal e As System.EventArgs) Handles mybrowser.DocumentCompleted
Console.WriteLine("document " + mybrowser.Document.Url.AbsoluteUri)
End Sub
结果是(用http://youtube.com测试)
navigating http://youtube.com/
navigated http://www.youtube.com/
document http://www.youtube.com/
navigating http://www.google.com/pagead/drt/ui
navigated wyciwyg://0/http://www.youtube.com/
navigating wyciwyg://0/http://www.youtube.com/
document http://www.youtube.com/
navigating about:blank
document http://www.youtube.com/
document http://www.youtube.com/
如您所见,该站点多次重定向和触发导航事件,包括缓存、google pagead 站点和 about:blank(???)。每个导航事件都将由 documentcompleted 事件结束。
那么,如果我只想知道浏览器何时真正完成了对网站的浏览,无论有多少重定向,我应该听什么事件?