[點(diǎn)晴永久免費(fèi)OA]C#WebBrowser中html元素如何觸發(fā)winform事件
void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { HtmlElement link = this.webBrowser1.Document.GetElementById("test");//找到元素 link.Click += new HtmlElementEventHandler(Form1_Click); //添加 點(diǎn)擊事件處理函數(shù) } void Form1_Click(object sender, HtmlElementEventArgs e) { try { if (this.webBrowser1.Document.GetElementById("test_v").InnerText.ToString() != "") { MessageBox.Show("您點(diǎn)擊了按鈕:" + this.webBrowser1.Document.GetElementById("test_v").InnerText.ToString()); this.webBrowser1.Document.GetElementById("test_v").InnerText = ""; } } catch(Exception) { } } private void Form1_Load(object sender, EventArgs e) { this.webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); }
該文章在 2017/3/30 23:39:44 編輯過(guò) |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |