只有在vb.net webbrowser中完全加载了特定的URL时,如何在子例程中运行一些东西。
e.g。
sub button click
webbrowsernavigate to whatever
(This is what I need)if document has loaded statement
do stuff
end sub
谢谢
答案 0 :(得分:1)
WebBrowser
类有一个DocumentCompleted
事件可以绑定到:
在
WebBrowser
控件完成加载文档时发生。
MSDN文章有一个示例,演示了如何有效地使用此事件:
Private Sub PrintHelpPage()
' Create a WebBrowser instance.
Dim webBrowserForPrinting As New WebBrowser()
' Add an event handler that prints the document after it loads.
AddHandler webBrowserForPrinting.DocumentCompleted, New _
WebBrowserDocumentCompletedEventHandler(AddressOf PrintDocument)
' Set the Url property to load the document.
webBrowserForPrinting.Url = New Uri("\\myshare\help.html")
End Sub
Private Sub PrintDocument(ByVal sender As Object, _
ByVal e As WebBrowserDocumentCompletedEventArgs)
Dim webBrowserForPrinting As WebBrowser = CType(sender, WebBrowser)
' Print the document now that it is fully loaded.
webBrowserForPrinting.Print()
MessageBox.Show("print")
' Dispose the WebBrowser now that the task is complete.
webBrowserForPrinting.Dispose()
End Sub