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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

How to get the click's URL?

Post Reply
was
Posts: 4
Joined: Sun Jan 22, 2023 2:02 pm

How to get the click's URL?

Post by was »

Hi, how to get the URL when click the link before loading... thank you!
User avatar
salvadordf
Posts: 4620
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to get the click's URL?

Post by salvadordf »

Hi,

Use the TWVBrowser.OnNavigationStarting event and create a TCoreWebView2NavigationStartingEventArgs instance like this :

Code: Select all

uses
  uWVCoreWebView2Args;
...
procedure TMiniBrowserFrm.WVBrowser1NavigationStarting(Sender: TObject; const aWebView: ICoreWebView2; const aArgs: ICoreWebView2NavigationStartingEventArgs);
var
  TempArgs: TCoreWebView2NavigationStartingEventArgs;
begin
  TempArgs := TCoreWebView2NavigationStartingEventArgs.Create(aArgs);
  if TempArgs.IsUserInitiated then
    begin
      // Use TempArgs.URI here. It has the link that the user clicked.
    end;
  TempArgs.Free;  
end;
was
Posts: 4
Joined: Sun Jan 22, 2023 2:02 pm

Re: How to get the click's URL?

Post by was »

Very good, thanks a lot.
Post Reply