vb /WebBrowser 网页中的图片按钮怎么实现模拟点击
网页源码<tdvalign="bottom"><INPUTtype="image"src="images/cx_enter.gif"width="41"height="1...
网页源码<td valign="bottom"><INPUT type="image" src="images/cx_enter.gif" width="41" height="16" border=0 name="imageField"> <img src="images/cx_reset.gif" width="41" height="16" border="0" style="cursor:hand;" onClick="MM_openBrWindow('readme.asp','','scrollbars=yes,width=500,height=400')" /></td>
展开
展开全部
实现模拟网页点击按钮的功能代码如下:
Private Sub Command1_Click()
WB1.Navigate Text1
End Sub
Private Sub Command2_Click()
Timer1.Enabled = True
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command4_Click()
Dim vDoc, vTag
Dim I As Integer
Set vDoc = WB1.Document
List1.Clear
For I = 0 To vDoc.All.length - 1
If UCase(vDoc.All(I).tagName) = "INPUT" Then
Set vTag = vDoc.All(I)
If vTag.Type = "submit" Then
List1.AddItem vTag.Name
Select Case vTag.Name
Case "btnBack"
vTag.Click
End Select
End If
End If
Next I
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim a As Long
a = a + 1
Label1 = "已经运行了" & Fix(a / 60) & "分钟"
If a Mod 600 = 0 Then
Command4_Click
End If
End Sub
Private Sub Command1_Click()
WB1.Navigate Text1
End Sub
Private Sub Command2_Click()
Timer1.Enabled = True
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Command4_Click()
Dim vDoc, vTag
Dim I As Integer
Set vDoc = WB1.Document
List1.Clear
For I = 0 To vDoc.All.length - 1
If UCase(vDoc.All(I).tagName) = "INPUT" Then
Set vTag = vDoc.All(I)
If vTag.Type = "submit" Then
List1.AddItem vTag.Name
Select Case vTag.Name
Case "btnBack"
vTag.Click
End Select
End If
End If
Next I
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Dim a As Long
a = a + 1
Label1 = "已经运行了" & Fix(a / 60) & "分钟"
If a Mod 600 = 0 Then
Command4_Click
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-12-14 · 知道合伙人互联网行家
关注
展开全部
Private Sub web_DocumentComplete(ByVal pDisp As Object, URL As Variant)
On Error Resume Next
set aa=web.Document.getElementsByTagName("img")
For Each a In aa
tmp=a.src
If InStr(tmp, "reset.gif") > 0 Then '按图片地址识别,点它
'a.scrollIntoView
a.Click
Exit For
End If
Next
Set aa = Nothing
On Error Resume Next
set aa=web.Document.getElementsByTagName("img")
For Each a In aa
tmp=a.src
If InStr(tmp, "reset.gif") > 0 Then '按图片地址识别,点它
'a.scrollIntoView
a.Click
Exit For
End If
Next
Set aa = Nothing
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
看一下dom吧,web控件有一个属性叫document,我们可以使用它的函数:getelementById或者getelementByTagName来查找页面中的元素,然后调用它的click方法就ok了。
更多追问追答
追问
源代码为INPUT type="image" src="images/cx_enter.gif" width="41" height="16" border=0 name="imageField">
可否写成 vDoc.All.Item("imageField").Click
追答
貌似不行哦,你用getelementByName获得这个input后,再调用不久得啦
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询