How to know that WebBrowser control has finished loading all content including flash?

喜你入骨 提交于 2019-12-11 07:34:24

问题


is there a way to know that the WebBrowser control has finished loading the page?
currently i am using WebBrowser.ReadyState == WebBrowserReadyState.Complete.
but this indicates that the webpage content is downloaded but sometimes the flash is not loaded yet.


回答1:


A Flash file loading doesn't report its progress on that back to the browser so unfortunately you can't catch that.




回答2:


well the best thing i have found is to use a timer to wait for a specifique time like 30 seconds and then the page should be loaded.
not perfect but the best i have thought of.




回答3:


If you have control over the Flash, you can put an ActionScript event that will then get passed to the browser.




回答4:


The WebBrowser control has a DocumentCompleted event which you can catch and react on. I don't know if that includes the Flash content loading - the docs aren't very clear on that....

webBrowser1.DocumentCompleted += 
     new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);

private void webBrowser1_DocumentCompleted(object sender, 
                                     WebBrowserDocumentCompletedEventArgs e)
{
   // do whatever you need to do when the document is completely loaded here
}



回答5:


You can try this way:

bool loadingPage = true;

private void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
     if (this.ReadyState != WebBrowserReadyState.Complete) return;
     if ((e.Url.AbsolutePath == "blank") || (e.Url != this.Url)) return;
     if (this.Document.Body.All.Count < 20) return;
     loadingPage = false
}

private void WaitPageLoad()
{
     //To avoid waiting forever. You can add timer here.
     while(loadingPage)
     {
     }
}


来源:https://stackoverflow.com/questions/1996268/how-to-know-that-webbrowser-control-has-finished-loading-all-content-including-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!