|
-
Apr 19th, 2011, 10:19 PM
#1
Thread Starter
Member
[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
-
Apr 19th, 2011, 10:31 PM
#2
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.
Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
- Abraham Lincoln -
-
Apr 19th, 2011, 10:45 PM
#3
Thread Starter
Member
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
-
Apr 19th, 2011, 11:35 PM
#4
Re: WebBrowser1.Navigate wait for finish
The IsBusy and State properties of the WebBrowser can tell you whether a sub-document is still loading.
-
Apr 19th, 2011, 11:50 PM
#5
Thread Starter
Member
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
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|