TheGateKeeper
TheGateKeeper

Reputation: 4540

Checking if WebBrowser has loaded

If I have

browser.Navigate("http://www.test.com");

In a method, how can I check if it has loaded the webpage from within the same method?

Thanks.

Upvotes: 3

Views: 9040

Answers (2)

FarhadMohseni
FarhadMohseni

Reputation: 424

This is Worked For Me:

//Waiting For WebBrowser Load

   while(browser.ReadyState == WebBrowserReadyState.Loading) {


   Application.DoEvents();


 }  
      //Do Smth.....

Upvotes: 1

Ry-
Ry-

Reputation: 225273

To check if it's loaded wherever, do:

if(browser.ReadyState == WebBrowserReadyState.Complete) {
    // It's done!
}

However, if you're waiting for it to load, handle the DocumentCompleted event instead:

browser.DocumentCompleted += WhenItsDone;

Upvotes: 8

Related Questions