Block new windows - load in main window

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Block new windows - load in main window

Postby Fumarmata » Thu Sep 20, 2018 11:09 am

Hello,

I have embedded CEF in my app and I would like it to never spawn new windows / popups, but load them in the same window.

How can I accomplish that? Where can I start looking?

Thanks
Fumarmata
Newbie
 
Posts: 2
Joined: Thu Sep 20, 2018 11:07 am

Re: Block new windows - load in main window

Postby Czarek » Fri Sep 21, 2018 8:40 am

Implement CefLifeSpanHandler::OnBeforePopup: https://github.com/chromiumembedded/cef ... dler.h#L56

There is no "tabs" feature in CEF, so you only have to take care of popups.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Block new windows - load in main window

Postby Fumarmata » Fri Sep 21, 2018 10:43 am

Thanks!
If somebody unexperienced like me wants to try, changing the contents of the method to this will make the popup open in the same window:
Code: Select all
   browser->GetMainFrame()->LoadURL(target_url);
   return true;
Last edited by Fumarmata on Fri Sep 21, 2018 11:49 am, edited 1 time in total.
Fumarmata
Newbie
 
Posts: 2
Joined: Thu Sep 20, 2018 11:07 am

Re: Block new windows - load in main window

Postby HarmlessDave » Fri Sep 21, 2018 11:46 am

You need to cancel the popup by returning true, but you also need to have the parent window do the same navigation by having it load the request.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 54 guests