C# webBrowser 自动确定confirm()对话框 请问各位高手:C# webBrowser 如何控制确定confirm()对话框! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 //from msdnHtmlWindow orderWindow; HtmlElement formElement; private void LoadOrderForm() { if (!(webBrowser1.Document == null)) { HtmlDocument doc = webBrowser1.Document; orderWindow = doc.Window.OpenNew(new Uri("file://C:\\orderForm.htm"), ""); //!TODO: Perform this in the load event handler! // Get order form. HtmlElementCollection elemCollection = doc.All.GetElementsByName("NewOrderForm"); if (elemCollection.Count == 1) { formElement = elemCollection[0]; //!TODO: Awaiting DCR //formElement.AttachEventHandler("onsubmit", new HtmlElementEventHandler(Form_Submit)); } } } private void Form_Submit(object sender, HtmlElementEventArgs e) { bool doOrder = orderWindow.Confirm("Once you transmit this order, you cannot cancel it. Submit?"); if (!doOrder) { //Cancel the submit. e.ReturnValue = false; orderWindow.Alert("Submit cancelled."); } } void wb_NavigateComplete2(object pDisp, ref object URL) { mshtml.IHTMLDocument2 doc = (this.webBrowser1.ActiveXInstance as SHDocVw.WebBrowser).Document as mshtml.IHTMLDocument2; doc.parentWindow.execScript("function alert(str){return ''}", "javascript"); } 都是 var 这样好用吗? PLC和C#串行通信问题 妄自定论:CSDN里最难得问题!C/S程序有关Word表单内容操作的问题! 用c#开发c/s结构程序有前途吗? 如何遍历该泛型,类型为CLASS,我要获得Class中属性的值 关于如何取得坐标准确值的问题 简单问题(急) c# ado.net 的使用 产生了一点问题 求大神指点 C# 调用.dll的问题 有没有参加微软夏令营的人啊? C#能做些什么 怎么才能学好C# 虔诚的请教 引用的dll文件不存在的错误处理
//from msdn
HtmlWindow orderWindow;
HtmlElement formElement; private void LoadOrderForm()
{
if (!(webBrowser1.Document == null))
{
HtmlDocument doc = webBrowser1.Document;
orderWindow = doc.Window.OpenNew(new Uri("file://C:\\orderForm.htm"), ""); //!TODO: Perform this in the load event handler!
// Get order form.
HtmlElementCollection elemCollection = doc.All.GetElementsByName("NewOrderForm");
if (elemCollection.Count == 1)
{
formElement = elemCollection[0];
//!TODO: Awaiting DCR
//formElement.AttachEventHandler("onsubmit", new HtmlElementEventHandler(Form_Submit));
}
}
} private void Form_Submit(object sender, HtmlElementEventArgs e)
{
bool doOrder = orderWindow.Confirm("Once you transmit this order, you cannot cancel it. Submit?");
if (!doOrder)
{
//Cancel the submit.
e.ReturnValue = false;
orderWindow.Alert("Submit cancelled.");
}
}
{
mshtml.IHTMLDocument2 doc = (this.webBrowser1.ActiveXInstance as SHDocVw.WebBrowser).Document as mshtml.IHTMLDocument2;
doc.parentWindow.execScript("function alert(str){return ''}", "javascript");
}