예제 #1
0
        protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefWindowOpenDisposition targetDisposition, bool userGesture, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess)
        {
            var e = new BeforePopupEventArgs(frame, targetUrl, targetFrameName, popupFeatures, windowInfo, client, settings,
                                             noJavascriptAccess);

            _core.InvokeIfRequired(() => _core.OnBeforePopup(e));

            client             = e.Client;
            noJavascriptAccess = e.NoJavascriptAccess;

            return(e.Handled);
        }
        internal protected virtual void OnBeforePopup(BeforePopupEventArgs e)
        {
            if (IsCanShowPopWindow)
            {
                if (BeforePopup != null)
                {
                    BeforePopup(this, e);
                }
                else
                {
                    e.Handled = false;
                }
            }
            else
            {
                if (BeforePopup != null)
                {
                    e.Handled = true;//标记为事件已经接受处理完毕

                    //CefWebBrowser clone = new CefWebBrowser();
                    //e.WindowInfo.SetAsChild(clone.Handle, new CefRectangle { X = 0, Y = 0, Width = Width, Height = Height });

                    //BeforePopup(this, e);
                    ///e.Frame.Browser.GetHost()

                    //直接在当前页面进行跳转
                    e.Frame.Browser.GetMainFrame().LoadUrl(e.TargetUrl);

                    BeforePopup(this, e);
                }
                else
                {
                    e.Handled = false;
                }
            }
        }