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.

How to intercept and open a given url in a new window

Post Reply
darkducke
Posts: 21
Joined: Thu Feb 15, 2018 4:29 pm

How to intercept and open a given url in a new window

Post by darkducke »

I need to check if the browser will navigate to the url ""https://www.example.com" and make it open in another CEFWindowParent that I have in the form maintaining the user session and canceling the current browser navigation, keeping on the same page.

I checked that there are "OnBeforeBrowse" and "OnBeforeResourceLoad" events. My question is, which of these should I use and how to share the user session logged in Browser1 to Browser2

Thanks a lot for any help!
User avatar
salvadordf
Posts: 4057
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to intercept and open a given url in a new window

Post by salvadordf »

Hi,

You can use the TChromium.OnBeforeBrowse event and set the "Result" parameter to TRUE to cancel the navigation if request.Url has certain value.

Then save the request.Url value and create a new browser2 in the main application thread that will have request.Url as the TChromium.DefaultUrl property value.

This should work on most cases as long as both browsers share the same cache directory but if the original request had some POST information then you will lose it.

If the user clicked on a link that required a new tab or new window the browser would trigger the TChromium.OnBeforePopup or TChromium.OpenUrlFromTab events. See the TabbedBrowser2 demo for more details about handling these events.
Post Reply