Web browser control fires many times during website load

mickle026

Member
Joined
Oct 31, 2009
Messages
20
Programming Experience
3-5
Hi guys

I dont know how to do this, I am looking for how to find out when the web browser control has finished loading completely.

On serveral sites the pages loads in parts and is probably built from sections - like php /asp or iFrames.

My problem is that I only want to trigger my parsing routines when it is fully complete but it is triggering as many as 8 times during a page load as each segment completes.

Is there anyway to detect if its completely loaded all parts?

An example site that does this (amongst many) is IMDb

This post:
http://www.vbdotnetforums.com/other...completed-event-passes-no-pdisp-argument.html

This post sort of touches on having to get each element, but I want to know what is or how do I detect fully completed page loading?

Thanks for any help on this matter.
 
Hi,

Ah, jmcilhinney just beat me to it, but I was going to say:-

You need to check the ReadyState property of the Web Browser instance. i.e:-

VB.NET:
Private Sub myWebBrowser_DocumentCompleted(sender As System.Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles myWebBrowser.DocumentCompleted
  If myWebBrowser.ReadyState = WebBrowserReadyState.Complete Then
    'Your code goes here!
  End If
End Sub

Hope that helps.

Cheers,

Ian
 
Thanks

This is much better. It fires twice for some reason when I initiate the browser control with a homepage (example- on imdb), but from then on only once so far on the previous problem pages.

Very helpful.

Many thanks :joyous:
 
Back
Top