El control WebBrowser tiene un estado extraño [duplicado]

Posible duplicado:
¿Cómo usar el evento DocumentCompleted de control de WebBrowser en C #?

Could someone tell me why DocumentCompleted event happens 3 times???

How do I know that document is REALLY has been downloaded?

(I used some pages to test that have a lot of jQuery.)

¡Gracias!

var webBrowser1 = new WebBrowser
                {
                    Padding = new Padding(0),
                    Margin = new Padding(0),
                    Dock = DockStyle.Fill,
                    Url = url,
                    TabStop = false,
                    ScriptErrorsSuppressed = true,
                    IsWebBrowserContextMenuEnabled = false
                };
                webBrowser1.Navigated +=  (d1,d2) => 
                {
                    Debug.WriteLine("Navigated " + DateTime.Now.TimeOfDay.ToString());
                };
                webBrowser1.DocumentCompleted += (d1, d2) => 
                {
                    Debug.WriteLine("DocumentCompleted " + DateTime.Now.TimeOfDay.ToString());                
                };


                form.Controls.Add(webBrowser1);
                form.Show();

INICIAR SESIÓN:

Navigated 09:40:40.1807403 Navigated 09:40:44.7270004 DocumentCompleted 09:40:44.7300005 Navigated 09:40:46.5791063 DocumentCompleted 09:40:46.5821065 Navigated 09:40:50.1113083 DocumentCompleted 09:40:50.7133428 DocumentCompleted 09:40:50.7233433

preguntado el 28 de agosto de 12 a las 13:08

1 Respuestas

I found a good approach here

¿Cómo usar el evento DocumentCompleted de control de WebBrowser en C #?

 webBrowser1.DocumentCompleted += (d1, d2) => 
                {


                    string urlCurrent = d2.Url.ToString();
                    var browser = (WebBrowser)d1;

                    if (!(urlCurrent.StartsWith("http://") || urlCurrent.StartsWith("https://")))
                    {
                        // in AJAX     
                    }
                    if (d2.Url.AbsolutePath != browser.Url.AbsolutePath)
                    {
                        // IFRAME           
                    }
                    else
                    {
                        // REAL DOCUMENT COMPLETE

                        Debug.WriteLine("DocumentCompleted " + DateTime.Now.TimeOfDay.ToString());
                    }

                };

contestado el 23 de mayo de 17 a las 13:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.