[RESOLVED] WebBrowser1.Navigate wait for finish
Ok i want the browser to so something like this:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
WebBrowser1.Document.GetElementById("Login").SetAttribute("Value",TextBox1.Text)
WebBrowser1.Document.GetElementById("pass").SetAttribute("Value",TextBox2.Text)
WebBrowser1.Document.GetElementById("login).InvokeMember("click")
'now the problem is that the following statments finishes up before the preceding statment
Dim PageTeamElements As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("a")
For Each CurElement As HtmlElement In PageTeamElements
CurElement.GetAttribute("href")
TextBox3.Text = TextBox3.Text & CurElement.GetAttribute("href") & Environment.NewLine
Next
Dim PageUserElements As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("img")
For Each CurElement As HtmlElement In PageUserElements
CurElement.GetAttribute("src")
TextBox3.Text = TextBox3.Text & CurElement.GetAttribute("src") & Environment.NewLine
Next
End Sub
How can i wait for browser to do
WebBrowser1.Document.GetElementById("login).InvokeMember("click")
then fetch data
and then again to navigate somewhere else (by using WebBrowser1.Navigate("some other link"))
and to fetch data from there completes
Re: WebBrowser1.Navigate wait for finish
You handle the webbrowser.documentcompleted event and examine the Url property of the webbrowserdocumentcompletedeventargs e to find out which page has just completed and proceed accordingly.
Re: WebBrowser1.Navigate wait for finish
i have been trying to figure it out for hours but i just can't get it.
The problem is that i have a WebBrowser1.Navigate on the form load, so document complete happens a few times
Re: WebBrowser1.Navigate wait for finish
The IsBusy and State properties of the WebBrowser can tell you whether a sub-document is still loading.
Re: WebBrowser1.Navigate wait for finish
vb Code:
If Not WebBrowser1.IsBusy Then
If WebBrowser1.Url.AbsoluteUri = "url i need" Then
do something
end if
end if
got it done with this :)