当前位置: 首页 > 工具软件 > SharpPDF > 使用案例 >

使用CefSharp跳转页面不弹出页面:

俞子实
2023-12-01
using CefSharp;
using CefSharp.Wpf;
namespace Common.Control
{
    internal class CefSharpOpenPageSelf : ILifeSpanHandler
    {
        public bool DoClose(IWebBrowser browserControl, IBrowser browser)
        {
            return false;
        }
        public void OnAfterCreated(IWebBrowser browserControl, IBrowser browser)
        {
        }
        public void OnBeforeClose(IWebBrowser browserControl, IBrowser browser)
        {
        }
        public 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)
        {
            newBrowser = null;
            var chromiumWebBrowser = (ChromiumWebBrowser)browserControl;
            chromiumWebBrowser.Load(targetUrl);
            return true; //Return true to cancel the popup creation copyright by  codebye.com.
        }
    }
}

 

转载于:https://www.cnblogs.com/TimLiuDream/p/9897932.html

 类似资料: