954,541 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Webbrowser navigate to page, wait for the page to load then move to the next page

Hello people :) I need some help. How can I get Webbrowser1 to navigate to each page and wait for the one page to completely load, then move to the next page...?

Thank you for answers in advance! ;)


Example.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click



WebBrowser1.Navigate("http://www.google.com") 'Wait for a page to completely load and continue...


WebBrowser1.Navigate("http://www.daniweb.com/forums/")   'Wait for a page to completely load and continue...


WebBrowser1.Navigate("http://msdn.microsoft.com/lt-lt/default(en-us).aspx")     'Wait for a page to completely load and continue...



WebBrowser1.Navigate("http://www.learnvisualstudio.net/")     'Wait for a page to completely load and continue...

End Sub

I tried this, but it doesnt work well.

If WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
WebBrowser1.Navigate("http://www.learnvisualstudio.net/")
        End If
Mindazz
Newbie Poster
7 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 


Heres "A" way to do it.

This will navigate back and forth from google.com and yahoo.com, every 10 seconds after the page is loaded.

Public Class Form1
    Private urls() As String = {"http://www.google.com", _
                                "http://www.yahoo.com"}
    Private index As Integer
    Private WithEvents navtimer As New Timer

    Private Sub Form1_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
        navtimer.Interval = 10000
        WebBrowser1.Navigate(urls(index))
        index += 1
    End Sub

    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
        lblDone.Text = urls(index - 1)
        navtimer.Start()
    End Sub

    Private Sub navtimer_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles navtimer.Tick
        If WebBrowser1.IsBusy Then Exit Sub
        If index > UBound(urls) Then index = 0
        WebBrowser1.Navigate(urls(index))
        index += 1

        navtimer.Stop()
    End Sub
End Class
Unhnd_Exception
Posting Pro
570 posts since Nov 2010
Reputation Points: 249
Solved Threads: 201
 

Thanks man it works great :) +rep

Mindazz
Newbie Poster
7 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
 


I have a simple question.
I'm making google urls bot and your code it works great,but it
is not in this way i want to.
It loads well but in form load.

Can someone knows how to load and move next page and so on itself and collect all links from google using textbox or listbox in document_complated ?

To make it loop for all google pages like 1,2,3,4,5,6,7,8,9,10 and so on.

Thanks.

polas5
Newbie Poster
4 posts since Jul 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: