Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
Namue
Posts: 4 Joined: Fri Mar 06, 2020 6:55 am
Post
by Namue » Fri Mar 06, 2020 9:47 am
I want to show an error page, if the url could not be loaded. By default the component shows an white page.
I have 2 cases:
The URL is valid, but can not be reached (e.g. server ist offline / error in spelling).
In Chrome Browser, there is an error page shown.
I solved this by using the TChromium.OnLoadError and call a TChromium.LoadString to show my own error page. This works.
The URL is invalid (e.g. the user added an number too much to the port by mistake - so that the maximum is exceeded)
In Chrome Browser, there is an redirect to the google search.
I found no solution to get an event for this case. Does anyone know a possibility?
salvadordf
Posts: 4575 Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:
Post
by salvadordf » Fri Mar 06, 2020 9:58 am
Hi,
You can use TChromium.OnLoadError for both situations.
Use the "
errorCode " parameter to generate a custom HTML error page that you can load with TChromium.LoadString. errorCode can have these values :
https://github.com/salvadordf/CEF4Delph ... ts.pas#L66
You can also check the "
failedUrl " parameter to see if there are any errors and call TChromium.LoadURL to redirect the browser to any website.
Namue
Posts: 4 Joined: Fri Mar 06, 2020 6:55 am
Post
by Namue » Fri Mar 06, 2020 10:10 am
I already tried the TChromium.OnLoadError for both cases.
The first case works fine.
In the second case the event is not called. I already set a breakpoint to TChromiumCore.doOnLoadError, but the code is not called.
Is there maybe an setting I have to do before?
Namue
Posts: 4 Joined: Fri Mar 06, 2020 6:55 am
Post
by Namue » Fri Mar 06, 2020 1:52 pm
TChromium.OnBeforeBrowse is also not called, if the URL is invalid.
salvadordf
Posts: 4575 Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:
Post
by salvadordf » Fri Mar 06, 2020 1:56 pm
...then the only thing we can do is to check the URL even before we call TChromium.LoadURL
Namue
Posts: 4 Joined: Fri Mar 06, 2020 6:55 am
Post
by Namue » Fri Mar 06, 2020 3:20 pm
Ok, I did so. Thanks for your help.