|
- private void webBrowser1_Completed(object sender, WebBrowserDocumentCompletedEventArgs e)
- {
- if (webBrowser1.ReadyState != WebBrowserReadyState.Complete) return;
- MessageBox.Show("完成加载");
- bt3_Click(sender, e);
- }
- private void bt3_Click(object sender, EventArgs e)
- {
- textBox1.Text = "";
- string url;
- HtmlElementCollection elemcoll = webBrowser1.Document.GetElementsByTagName("img");
- foreach (HtmlElement elem in elemcoll)
- {
- url = elem.GetAttribute("src");
- textBox1.Text += url;
- textBox1.Text += "\r\n";
- }
- url = textBox1.Text;
- string ex = "lg.php";
- if (url.IndexOf(ex) == -1)
- {
- webBrowser1.Refresh();
- }
- }
复制代码 当网页加载完成后会进入webBrowser1_Completed,执行bt3_Click(sender, e)这条语句,bt3_Click中判断是否存在名字为lg.php的图片,如果有就不做任何操作,如果没有则会对该网址进行刷新。
但是刷新后进入webBrowser1_Completed后,只执行if (webBrowser1.ReadyState != WebBrowserReadyState.Complete) return;
不执行MessageBox.Show("完成加载")及后面的语句就跳出去了,不清楚为什么?
请大家帮忙看看
|
|