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.

block pop-ups plz

Post Reply
sodlf159
Posts: 90
Joined: Thu Nov 09, 2023 1:55 pm

block pop-ups plz

Post by sodlf159 »

How do I block pop-ups asking me to select an app from appearing?
Chrome itself is currently updating its version.
A pop-up window will appear allowing you to select the page and open the link app in the format.
I want to block this.
User avatar
salvadordf
Posts: 4620
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: block pop-ups plz

Post by salvadordf »

See the SimpleBrowser2 demo :
https://github.com/salvadordf/CEF4Delphi/blob/00bf20f147679db82d37cc69f37ff8663f90f2de/demos/Delphi_VCL/SimpleBrowser2/uSimpleBrowser2.pas#L143

Implement TChromiumCore.OnBeforePopup and TChromiumCore.OnOpenUrlFromTab
Set Result to TRUE when "targetDisposition" has any of these values : CEF_WOD_NEW_FOREGROUND_TAB, CEF_WOD_NEW_BACKGROUND_TAB, CEF_WOD_NEW_POPUP, CEF_WOD_NEW_WINDOW
sodlf159
Posts: 90
Joined: Thu Nov 09, 2023 1:55 pm

Re: block pop-ups plz

Post by sodlf159 »

Thanks. Is there a similar function for WebView4?
User avatar
salvadordf
Posts: 4620
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: block pop-ups plz

Post by salvadordf »

The KioskBrowser demo in WebView4Delphi shows how to block popup windows using the TWVBrowser.OnNewWindowRequested event :
https://github.com/salvadordf/WebView4Delphi/blob/b0cfcb2f551bb589e4ce6456b847d9e2aee2acc0/demos/Delphi_VCL/KioskBrowser/uKioskBrowser.pas#L179

Create a TCoreWebView2NewWindowRequestedEventArgs instance with "aArgs" and set its Handled property to True.

Read the code comments about TCoreWebView2NewWindowRequestedEventArgs for all the details.
Post Reply