When using CEF, the page that is loaded, if there is a link in it, specifies target= "_blank", a new browser window will pop up. If you want to disable, let the new page appear in the current browser window, you can rewrite the Ceflifespanhandler Onbeforepopup method in the handler of the browser process, and load the URL of the popup request with browser mainframe. The code is as follows:
bool SimpleHandler::OnBeforePopup(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name, WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, bool* no_javascript_access){ switch (target_disposition) { case WOD_NEW_FOREGROUND_TAB: case WOD_NEW_BACKGROUND_TAB: case WOD_NEW_POPUP: case WOD_NEW_WINDOW: browser->GetMainFrame()->LoadURL(target_url); return true; //cancel create } return false;}
The first parameter of the Onbeforepopup function browser represents the browser object that issued the popup request, and the frame is the target to be loaded by the Frame,target_url that issued the popup request url,target_ Disposition is the display mode. We'll just have to take care of these parameters, load a new URL with browser mainframe for a specific number of WOD, return True, and end the process of creating a new window.
There is also some discussion about this requirement: http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=196. It refers to the modification of the DOM or modified CEF source code to achieve, also can refer to.
That's it.
Other reference articles are described in my column: "CEF and Ppapi development ".
Disable pop-up browser window in CEF