I am trying to avoid js alert on a page as it breaks the flow and the browser is stuck on that page until the popup is clicked.
I added Class as shown on sample:
public class JsDialogHandler : IJsDialogHandler
{
public bool OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage)
{
return true;
}
public bool OnJSBeforeUnload(IWebBrowser browserControl, IBrowser browser, string message, bool isReload, IJsDialogCallback callback)
{
return true;
}
public void OnResetDialogState(IWebBrowser browserControl, IBrowser browser)
{
}
public void OnDialogClosed(IWebBrowser browserControl, IBrowser browser)
{
}
}
And i assign to the Chromium browser as:
CefSharp.Cef.Initialize(new CefSharp.CefSettings());
browser = new CefSharp.WinForms.ChromiumWebBrowser(CustomLinks[0].ToString());
JsDialogHandler jss = new JsDialogHandler();
browser.JsDialogHandler = jss;
The thing is when alert is supposed to show it does run the OnJSDialog
event. But then the browser turns white and is just stuck and trying to find a way around but not much is available online..
Any suggestions?
callback
, read thexml doc
for instructions. – Firer