0

I have a simple code:

WebBrowser1.Navigate('www.foo.com');

But of course sometimes the browsing fails and the browser displays the error message.
How can I catch when this happens?
I want this so that I can make a some sort of a custom log.

Ken White
  • 123,280
  • 14
  • 225
  • 444
SmRndGuy
  • 1,719
  • 5
  • 30
  • 49
  • 1
    I wonder if you could check TWebBrowser.ReadyState for success (maybe in a while loop or using TTimer). If ReadyState doesn't return READYSTATE_COMPLETE in a reasonable time, raise your own error. – Max Williams Jul 19 '12 at 22:01

1 Answers1

3

I assume that the the OnNavigateError event handler is called when there is a problem.

Lawrence Barsanti
  • 31,929
  • 10
  • 46
  • 68
  • Strange but it seems that my TWebBrowser doesn't support OnNavigateError even doe I have found on MSDN that it is applied to it. Why is this? I am using Delphi7 btw. – SmRndGuy Jul 19 '12 at 20:54
  • Nope, I am absolutely sure that OnNavigateError is missing. Infact `WebBrowser1.onNavigateError:=;` throws an error telling that `onNavigateError` is not declared. What should I do? – SmRndGuy Jul 19 '12 at 21:07
  • 3
    @SmRndGuy: You're right; it's not there in D7. (D7 imports an extremely old version of the IE type library (`SHDocVw`). You may need to remove it and import a newer version of the type library to work with more modern versions of IE or use something like the freeware [TEmbeddedWB](http://www.bsalsa.com/product.html), which exposes more of the functionality. – Ken White Jul 19 '12 at 22:26
  • k. Now that I know what is the problem I can go on browsing and solving it. Thankyou. – SmRndGuy Jul 19 '12 at 23:18