How to use WebBrowser control DocumentCompleted event in C#?

前端 未结 5 1407
野性不改
野性不改 2020-11-27 16:14

Before starting writing this question, i was trying to solve following

// 1. navigate to page
// 2. wait until page is downloaded
// 3. read and write some d         


        
5条回答
  •  再見小時候
    2020-11-27 16:54

    You might want to know the AJAX calls as well.

    Consider using this:

    private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        string url = e.Url.ToString();
        if (!(url.StartsWith("http://") || url.StartsWith("https://")))
        {
                // in AJAX
        }
    
        if (e.Url.AbsolutePath != this.webBrowser.Url.AbsolutePath)
        {
                // IFRAME 
        }
        else
        {
                // REAL DOCUMENT COMPLETE
        }
    }
    

提交回复
热议问题