I have the following code
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (current_state == "request_4")
{
webBrowser1.Invoke(new Action(() => webBrowser1.ScriptErrorsSuppressed = true));
webBrowser1.Invoke(new Action(() => webBrowser1.Refresh(WebBrowserRefreshOption.Completely)));
InjectAlertBlocker();
}
}
private void InjectAlertBlocker()
{
HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[0];
HtmlElement scriptEl = webBrowser1.Document.CreateElement("script");
IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement;
string alertBlocker = "window.alert = function () { }";
element.text = alertBlocker;
head.AppendChild(scriptEl);
}
The refresh of the request I'm doing is POST request so WebBrowser instance is asking me all the the time if I want to "Retry" the request or not by showing Dialog window. How can I accept it or not show at all?
Suppressing errors or InjectAlertBlocker() doesn't help to do the trick.
I did not really understand http://www.codeproject.com/Articles/31163/Suppressing-Hosted-WebBrowser-Control-Dialogs this approach.
I appreciate if anyone can explain how to use that solution.