在WebBrowser中屏蔽对话框
/// <summary>
// 在WebBrowser中屏蔽对话框
/// </summary>
/// <param name="webBrowser">指定屏蔽对话框的WebBrowser</param>
public static void DisableMessageBox(ref WebBrowser webBrowser)
{
IHTMLWindow2 htmlWindow = (IHTMLWindow2)webBrowser.Document.Window.DomWindow;
htmlWindow.execScript("function alert(str){return true;}", "javascript");
htmlWindow.execScript("function window.alert(){return true;}", "javascript");
htmlWindow.execScript("function confirm(){return true;}", "javascript");
}
// 在WebBrowser中屏蔽对话框
/// </summary>
/// <param name="webBrowser">指定屏蔽对话框的WebBrowser</param>
public static void DisableMessageBox(ref WebBrowser webBrowser)
{
IHTMLWindow2 htmlWindow = (IHTMLWindow2)webBrowser.Document.Window.DomWindow;
htmlWindow.execScript("function alert(str){return true;}", "javascript");
htmlWindow.execScript("function window.alert(){return true;}", "javascript");
htmlWindow.execScript("function confirm(){return true;}", "javascript");
}