.Net : webBrowser弹出新页面,在当前Form窗体打开,可设置屏蔽当前网页的js错误。。。。
Posted on 2010-03-18 20:23 且行且思 阅读(1877) 评论(0) 编辑 收藏 举报 private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//将所有的链接的目标,指向本窗体
foreach (HtmlElement archor in this.webBrowser1.Document.Links)
{
archor.SetAttribute("target", "_self");
}
//将所有的FORM的提交目标,指向本窗体
foreach (HtmlElement form in this.webBrowser1.Document.Forms)
{
form.SetAttribute("target", "_self");
}
}
// this.webBrowser1.ScriptErrorsSuppressed = true; //屏蔽js相关错误。。。
private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
e.Cancel = true;
}
private void Form1_Load(object sender, EventArgs e)
{
webBrowser1.AllowWebBrowserDrop = false;
webBrowser1.WebBrowserShortcutsEnabled = false;
webBrowser1.IsWebBrowserContextMenuEnabled = false;
}