Files
cefsharp/CefSharp.WinForms/Handler/PopupCreation.cs
T
Alex Maitland 01b7a4330e WinForms - Add LifeSpanHandler.OnBeforePopupCreated
- Allow for cancelling of popup creation

browser.LifeSpanHandler = CefSharp.WinForms.Handler.LifeSpanHandler
	.Create()
	.OnBeforePopupCreated((chromiumWebBrowser, b, frame, targetUrl, targetFrameName, targetDisposition, userGesture, browserSettings) =>
	{
		//Can cancel opening popup based on Url if required.
		if(targetUrl?.StartsWith(CefExample.BaseUrl + "/cancelme.html") == true)
		{
			return PopupCreation.Cancel;
		}

		return PopupCreation.Continue;
	})
2022-01-10 13:44:30 +10:00

26 lines
722 B
C#

// Copyright © 2022 The CefSharp Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
namespace CefSharp.WinForms.Handler
{
/// <summary>
/// Popup Creation options
/// </summary>
public enum PopupCreation
{
/// <summary>
/// Popup creation is cancled, no further action will occur
/// </summary>
Cancel = 0,
/// <summary>
/// Popup creation will continue as per normal.
/// </summary>
Continue,
/// <summary>
/// Popup creation will continue with javascript disabled.
/// </summary>
ContinueWithJavascriptDisabled
}
}