Why is WebBrowser_DocumentCompleted() firing twice?

前端 未结 9 1405
独厮守ぢ
独厮守ぢ 2020-11-29 08:35

Well, I\'m using a simple webbrowser control to browse to a page, so I need to change the Text of the form while doing so. I\'m using -

private void webBrow         


        
9条回答
  •  旧时难觅i
    2020-11-29 08:54

    If firing twice is a problem then this should work:

      string body="";
    
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (body == webBrowser1.Document.Body.InnerHtml) return;
            body = webBrowser1.Document.Body.InnerHtml;
    
            // Here is something you want
        }
    

提交回复
热议问题