LifeSpanHandlerOnBeforePopup Method |
Version 130.1.90
Called before a popup window is created. By default the popup (browser) is created in a new native window.
Namespace: CefSharp.Wpf.ExperimentalAssembly: CefSharp.Wpf (in CefSharp.Wpf.dll) Version: 129.0.110.0 (129.0.110.0)
Syntax protected override bool OnBeforePopup(
IWebBrowser browserControl,
IBrowser browser,
IFrame frame,
string targetUrl,
string targetFrameName,
WindowOpenDisposition targetDisposition,
bool userGesture,
IPopupFeatures popupFeatures,
IWindowInfo windowInfo,
IBrowserSettings browserSettings,
ref bool noJavascriptAccess,
out IWebBrowser newBrowser
)
protected:
virtual bool OnBeforePopup(
IWebBrowser^ browserControl,
IBrowser^ browser,
IFrame^ frame,
String^ targetUrl,
String^ targetFrameName,
WindowOpenDisposition targetDisposition,
bool userGesture,
IPopupFeatures^ popupFeatures,
IWindowInfo^ windowInfo,
IBrowserSettings^ browserSettings,
bool% noJavascriptAccess,
[OutAttribute] IWebBrowser^% newBrowser
) override
Parameters
- browserControl IWebBrowser
[Missing <param name="browserControl"/> documentation for "M:CefSharp.Wpf.Experimental.LifeSpanHandler.OnBeforePopup(CefSharp.IWebBrowser,CefSharp.IBrowser,CefSharp.IFrame,System.String,System.String,CefSharp.WindowOpenDisposition,System.Boolean,CefSharp.IPopupFeatures,CefSharp.IWindowInfo,CefSharp.IBrowserSettings,System.Boolean@,CefSharp.IWebBrowser@)"]
- browser IBrowser
- The browser instance that launched this popup.
- frame IFrame
- The HTML frame that launched this popup.
- targetUrl String
- The URL of the popup content. (This may be empty/null)
- targetFrameName String
- The name of the popup. (This may be empty/null)
- targetDisposition WindowOpenDisposition
- The value indicates where the user intended to
open the popup (e.g. current tab, new tab, etc)
- userGesture Boolean
- The value will be true if the popup was opened via explicit user gesture
(e.g. clicking a link) or false if the popup opened automatically (e.g. via the DomContentLoaded event).
- popupFeatures IPopupFeatures
- structure contains additional information about the requested popup window
- windowInfo IWindowInfo
- window information
- browserSettings IBrowserSettings
- browser settings, defaults to source browsers
- noJavascriptAccess Boolean
- value indicates whether the new browser window should be scriptable
and in the same process as the source browser.
- newBrowser IWebBrowser
-
EXPERIMENTAL - Low level this allows for assigning the CefClient instance associated with the new ChromiumWebBrowser instance to the CefClient param of the CefLifeSpanHandler::OnBeforeBrowser method.
This allows for all the handlers, LifeSpanHandler, DisplayHandler, etc to be associated with the CefClient of the new ChromiumWebBrowser instance to be associated with the popup (browser).
WPF/WinForms specific code is still required to host the popup (browser) in the new ChromiumWebBrowser instance.
Set to null for default behaviour. If you return true (cancel popup creation) then his property **MUST** be null, an exception will be thrown otherwise.
Return Value
Boolean
By default the popup (browser) is opened in a new native window. If you return true then creation of the popup (browser) is cancelled, no further action will occur.
Otherwise return false to allow creation of the popup (browser).
Remarks
If you return true and set newBrowser to not null then an exception will be thrown as creation of the popup (browser) was cancelled.
WinForms - To host the popup (browser) in a TAB/Custom Window see https://github.com/cefsharp/CefSharp/wiki/General-Usage#winforms---hosting-popup-using-tab-control for an easy method.
WPF - For an example of hosting the popup (browser) in a custom window see https://github.com/cefsharp/CefSharp/wiki/General-Usage#wpf---hosting-popup-in-new-window-experimental
Same can be applied for hosting the popup in a TAB.
This method is still EXPERIMENTAL and will likely require upstream bug fixes in CEF (https://bitbucket.org/chromiumembedded/cef).
See Also