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事件下寫。