1. 綁定事件web
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { foreach (System.Windows.Forms.HtmlElement el in this.webBrowser1.Document.GetElementsByTagName("a")) { //if (el.Name == " btnG ") { el.Click += new HtmlElementEventHandler(HtmlElement1_MouseDown); } } }
2. 處理回調this
private void HtmlElement1_MouseDown(Object sender, HtmlElementEventArgs e) { //MessageBox.Show((sender as HtmlElement).InnerText); this.Text = (sender as HtmlElement).InnerText; }