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.

OnBeforeNavigate2 replacement

Post Reply
egold2005
Posts: 11
Joined: Mon Aug 24, 2020 9:32 am

OnBeforeNavigate2 replacement

Post by egold2005 »

Hello,

What would be the best event for replacing TWebBrowser.OnBeforeNavigate2, i need to examine the URL, perform certain actions and cancel the processing when they click on a link.

Thanks,
Eugene.
Student
Posts: 72
Joined: Tue Aug 07, 2018 9:20 am

Re: OnBeforeNavigate2 replacement

Post by Student »

Event OnBeforeBrowse, example

Code: Select all

if request.Url='https://www.google.com/' then
    Result := true;
egold2005
Posts: 11
Joined: Mon Aug 24, 2020 9:32 am

Re: OnBeforeNavigate2 replacement

Post by egold2005 »

Thank you.
egold2005
Posts: 11
Joined: Mon Aug 24, 2020 9:32 am

Re: OnBeforeNavigate2 replacement

Post by egold2005 »

1. Are there other events to use in the same scenario, because this one does not work well with my existing code.

2. Where can i read the documentation on this event?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: OnBeforeNavigate2 replacement

Post by salvadordf »

egold2005 wrote: Fri Sep 04, 2020 9:24 am 1. Are there other events to use in the same scenario, because this one does not work well with my existing code.
TChromium.OnBeforeResourceLoad is similar but TChromium.OnBeforeBrowse is the closest event to TWebBrowser.OnBeforeNavigate2
egold2005 wrote: Fri Sep 04, 2020 9:24 am 2. Where can i read the documentation on this event?
There are several ways to do that. Open the TChromiumCore source code in uCEFChromiumCore.pas and take a look at the events. You will see that they are grouped and each group has a comment with the name of an interface. For example, TChromiumCore.OnBeforeBrowse has ICefRequestHandler and TChromiumCore.OnBeforeResourceLoad has ICefResourceRequestHandler.

Open this page and scroll down a few paragraphs :
https://www.briskbard.com/index.php?lan ... =cef#usage

You will see a bunch of blue links with the name of the CEF classes bellow the text "As you can see in the source code, TChromium has the functions, procedures and events of"

Those classes have the same name as the previous interfaces but without the initial "I".

Click on the "CefRequestHandler" link to see the documentation for TChromiumCore.OnBeforeBrowse :
https://magpcss.org/ceforum/apidocs3/pr ... ndler.html

And click on the "CefResourceRequestHandler" link for more information about TChromiumCore.OnBeforeResourceLoad :
https://magpcss.org/ceforum/apidocs3/pr ... ndler.html

All the CEF documentation is here :
https://magpcss.org/ceforum/apidocs3/

It's a copy of the CEF code comments but the previous link is easier to navigate.
Post Reply