110,546
社区成员
发帖
与我相关
我的任务
分享
WebBrowser1.ScriptErrorsSuppressed = true; // C# 系统组件
AxWebBrowser1.Silent = true; // 静默, ATL COM
int AxWebBrowserIDocHostUi.OleInterfaces.IDocHostShowUI.ShowMessage(IntPtr hwnd, string lpstrText, string lpstrCaption, uint dwType, string lpstrHelpFile, uint dwHelpContext, ref int lpResult)
{
lpResult = 0;
if (lpstrText == "Hello222222")
{
if (MessageBox.Show("是否要屏蔽Alert对话框", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
MessageBox.Show("屏蔽鸟", "屏蔽鸟");
return Hresults.S_OK;
}
else
{
//
}
}
object obj = webBrowser1.ActiveXInstance;
AxWebBrowserIDocHostUi.OleInterfaces.IOleObject oc = obj as AxWebBrowserIDocHostUi.OleInterfaces.IOleObject;
oc.SetClientSite(this);
webBrowser1.Navigate(@"d:\bb.htm");
class EWebBrowser : System.Windows.Forms.WebBrowser
{
SHDocVw.IWebBrowser2 Iwb2;
protected override void AttachInterfaces(object nativeActiveXObject)
{
Iwb2 = (SHDocVw.IWebBrowser2)nativeActiveXObject;
Iwb2.Silent = true;
base.AttachInterfaces(nativeActiveXObject);
}
protected override void DetachInterfaces()
{
Iwb2 = null;
base.DetachInterfaces();
}
}