Wait for webpage to load

Instead of putting a random thread.sleep, how can I wait until everything from the webpage is loaded.

Htmlviewer1.loadurl(“google.ca”)
wait until the page loads… like all the advertisements and such

HTMLViewer.DocumentComplete

Have you read the Xojo manual?
or looked at the HTMLViewer reference?

I have however I’m had some issues with it (still having them).

I went to the Htmlviewer.documentcomplete event and entered in:
msgbox(“done loading”)

For some unknown reason, I got 5-6 message boxes (maybe because of advertisements on the page?)

Now in a real scenario, this would fire my code 5-6 times which would cause a lot of problems . How do I fix this?

I checked it again and it’s due to the advertisements.