예제 #1
0
        public bool OnJSDialog(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser,
                               string originUrl, CefSharp.CefJsDialogType dialogType, string messageText, string defaultPromptText,
                               CefSharp.IJsDialogCallback callback, ref bool suppressMessage)
        {
            switch (dialogType)
            {
            case CefSharp.CefJsDialogType.Alert:
                MessageBox.Show(messageText, "JavaScript", MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
                suppressMessage = true;
                return(false);

            case CefSharp.CefJsDialogType.Confirm:
                var dr = MessageBox.Show(messageText, "JavaScript");
                if (dr == MessageBoxResult.Yes)
                {
                    callback.Continue(true, string.Empty);
                    suppressMessage = false;
                    return(true);
                }
                else
                {
                    callback.Continue(false, string.Empty);
                    suppressMessage = false;
                    return(true);
                }

            case CefSharp.CefJsDialogType.Prompt:
                MessageBox.Show("系统不支持prompt形式的提示框", "JavaScript");
                break;

            default:
                break;
            }
            return(false);
        }
예제 #2
0
 public bool OnJSBeforeUnload(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, string message,
                              bool isReload, CefSharp.IJsDialogCallback callback)
 {
     return(true);
 }