webBrowser1.Document奇怪现象,该如何处理
webBrowser1.Document奇怪现象C# codeprivate void webBrowser1_DocumentCompleted(object sender, WebBro
webBrowser1.Document奇怪现象
C# codeprivate void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e){ //此触发事件事中所有webBrowser1.Navigat 要返回,用8标记 if (webBrowser1.Document.Url.ToString().Trim() != e.Url.ToString().Trim()) { if (e.Url.ToString() != "about: blank" && e.Url.ToString()!="javascript:fals") { return; } }textBox1.AppendText("文档完成"); //A some();}void some(){//不知道为什么执行到下面这句时,老是自动返回执行webBrowser1_DocumentCompleted触发事件,一共返回三次,才继续向下执行 hrefSearchCollection = webBrowser1.Document.GetElementsByTagName("table")[0].GetElementsByTagName("a");}
如上所述,有朋友遇到过吗?怎么解决??
[解决办法]while (webBrowser1.IsBusy) Application.DoEvents();
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.ReadyState < WebBrowserReadyState.Complete) return;
}
string LastUrl;
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (webBrowser1.ReadyState < WebBrowserReadyState.Complete || webBrowser1.Url.ToString() == LastUrl) return;
LastUrl = webBrowser1.Url.ToString();
}