HtmlElementCollection link =
this.webBrowser1.Document.GetElementsByTagName(
"
a
");
for ( int ii = 0; ii < link.Count; ii++)
{
if (link[ii].GetAttribute( " href ").ToLower().IndexOf( " /user_task?userid= ") == 0 && link[ii].GetAttribute( " href ").ToLower().IndexOf( " &st=0&p= ") > 0)
{
link[ii].InvokeMember( " click ");
}
for ( int ii = 0; ii < link.Count; ii++)
{
if (link[ii].GetAttribute( " href ").ToLower().IndexOf( " /user_task?userid= ") == 0 && link[ii].GetAttribute( " href ").ToLower().IndexOf( " &st=0&p= ") > 0)
{
link[ii].InvokeMember( " click ");
}
}
在C#中,使用webbrowser打开网页,在网页上点击链接打开网页,怎样实现还在控件中打开,而不是在IE中打开?
private void webBrowser1_NewWindow(object sender, CancelEventArgs e)
{
// 防止弹窗;
e.Cancel = true;
string url = this.webBrowser1.StatusText;
this.webBrowser1.Url = new Uri(url);
}
// 防止弹窗;
e.Cancel = true;
string url = this.webBrowser1.StatusText;
this.webBrowser1.Url = new Uri(url);
}
在NewWindow事件下写。