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.

Avoid websites opening in new tab / window

Post Reply
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Avoid websites opening in new tab / window

Post by thefunkyjoint »

Hi,

Certain websites when opened, open another url in a new tab or window and in this case, this url will open in a window outside the my app. Is there a way to avoid / block that behaviour ?

Thanks !
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Avoid websites opening in new tab / window

Post by salvadordf »

Use TChromium.OnBeforePopup and add this code to block new tabs, new windows and new popup windows :

Code: Select all

Result := (targetDisposition in [WOD_NEW_FOREGROUND_TAB, WOD_NEW_BACKGROUND_TAB, WOD_NEW_POPUP, WOD_NEW_WINDOW]);
Many demos use that code except MiniBrowser and PopupBrowser.
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Avoid websites opening in new tab / window

Post by thefunkyjoint »

Thank you Salvador ! :D
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Avoid websites opening in new tab / window

Post by thefunkyjoint »

Is there a way to make the popup url open inside the current TChromium instance, instead of only blocking it ?
thefunkyjoint
Posts: 513
Joined: Thu Aug 10, 2017 12:40 pm

Re: Avoid websites opening in new tab / window

Post by thefunkyjoint »

Nervermind, i got it ; just need to use the targetUrl parameter to navigate to the popup url.
Post Reply