[.NET] 有關WebBrowser的一些問題

看板Visual_Basic作者 (screct)時間14年前 (2011/06/14 17:41), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
請問各位一下 在VB 2010中,我製作一個表單上的按鈕A 希望當我按下這個按鈕A後 就以WebBrowser.Navigate(網址B) 去連結到網址B (網址B的網頁中,包含一個圖示C,) 並且在連結的同時達到, 按下圖示C的功能(啟動某項設備開關) 但是卻一直無法成功啟用 我的code如下: Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("IMG") For Each curElement As HtmlElement In theElementCollection If curElement.GetAttribute("src").ToString = "on.gif" Then curElement.InvokeMember("click") End If Next 圖示C的原始碼部分如下: <td> <input type='image' src = 'on.gif' onclick="newAJAXCommand('3?' + document.getElementById('ONString').value + '=I=3')"></td> 如果改成按下網頁中的另一個按鈕D 原始碼為: <tr><td><input type='button' class='smbuttons' value="Save and return" onclick="UpdateAllandgoback();"> </td> 使用以下code: Dim theElementCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("input") For Each curElement As HtmlElement In theElementCollection If curElement.GetAttribute("value").ToString = "Save and return" Then curElement.InvokeMember("click") End If Next 即可成功執行 想請問這是因為button和image之間的差異嗎? 若是這樣, 該如何修改code呢?? 謝謝各位! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.116.72.91 ※ 編輯: cff0000ff 來自: 140.116.72.91 (06/14 17:41) ※ 編輯: cff0000ff 來自: 140.116.72.91 (06/14 17:44)
文章代碼(AID): #1DzoozJs (Visual_Basic)
文章代碼(AID): #1DzoozJs (Visual_Basic)