none
Wait until webpage is loaded RRS feed

  • Question

  • Hi,

    I'm starting using the using the Microsoft Blend for Visual Professional 2015 and I'm having problems in having a routine to detect when the webpage is loaded.

    I've searched for solutions and the majority of them are around webbrowser.readystate and webbrowser.busy, but these comands are not recognized.

    I'm tried as well webbrowser.isloaded, but it return's always true even when the page is not loaded.

    What statement should I use to make a loop until the web page is loaded?

    Sunday, November 11, 2018 10:01 PM

Answers

  • Hi Karen,

    This is available in the System.Windows.Forms. My webBrowser is inside the System.Windows.Controls.

    Any idea how can I use the Documentcompleted the System.Windows.Controls, or other suggestions?

    Thanks in advance.

    Best Regards,

    Ricardo

    Hi,

    define a global variable

    Public Class Form1
        Dim completed = False
        Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            completed = True
        End Sub
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            WebBrowser1.Navigate("http://google.com")
            While Not completed
    
            End While
        End Sub
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 14, 2018 9:30 AM

All replies

  • If you are using a standard WebBrowser then DocumentCompleted is an event to use, similar to jQuery document ready.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    • Proposed as answer by Alex Li-MSFT Monday, November 12, 2018 9:05 AM
    Monday, November 12, 2018 3:16 AM
    Moderator
  • Hi,

    see the link ,it can help you

    https://stackoverflow.com/questions/3275515/how-to-wait-until-webbrowser-is-completely-loaded-in-vb-net

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 12, 2018 9:06 AM
  • Hi Karen,

    This is available in the System.Windows.Forms. My webBrowser is inside the System.Windows.Controls.

    Any idea how can I use the Documentcompleted the System.Windows.Controls, or other suggestions?

    Thanks in advance.

    Best Regards,

    Ricardo

    Tuesday, November 13, 2018 11:48 AM
  • Hi Karen,

    This is available in the System.Windows.Forms. My webBrowser is inside the System.Windows.Controls.

    Any idea how can I use the Documentcompleted the System.Windows.Controls, or other suggestions?

    Thanks in advance.

    Best Regards,

    Ricardo

    Hi,

    define a global variable

    Public Class Form1
        Dim completed = False
        Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
            completed = True
        End Sub
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            WebBrowser1.Navigate("http://google.com")
            While Not completed
    
            End While
        End Sub
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, November 14, 2018 9:30 AM
  • Many thanks!
    Wednesday, November 14, 2018 9:43 AM
  • Hi Karen,

    This is available in the System.Windows.Forms. My webBrowser is inside the System.Windows.Controls.

    Any idea how can I use the Documentcompleted the System.Windows.Controls, or other suggestions?

    Thanks in advance.

    Best Regards,

    Ricardo

    I would place any code into the DocumentCompleted event rather than set a variable to detect when the document was finish loading.

    Public Class Form3
        Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) _
            Handles WebBrowser1.DocumentCompleted
    
            Work()
    
        End Sub
        Private Sub Work()
            ' do whatever
        End Sub
    
        Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            WebBrowser1.Navigate("http://google.com")
        End Sub
    End Class


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Wednesday, November 14, 2018 11:33 AM
    Moderator