自动填表时如何激活INPUT中的onkeypress事件
1 解决方案1
2
3 Dim oDoc As HTMLDocument
4 Set oDoc = pDisp.Document
5
6 Dim oInput As HTMLInputElement
7 Set oInput = oDoc.getElementsByName("user")(0)
8 oInput.FireEvent "onkeypress"
9
10
11 解决方案2
12
13 Dim vDoc, vTag
14 Dim I As Integer
15 Set vDoc = WB1.Document
16 For I = 0 To vDoc.All.length - 1
17 If UCase(vDoc.All(I).tagName) = "INPUT" Then
18 Set vTag = vDoc.All(I)
19 If vTag.Type = "text" Then
20 Select Case vTag.Name
21 Case "username" '如果是用户名的那个框
22 vTag.Value = "用户名" '这个是用户名
23 vTag.onkeypress
24 End Select
25
26 End If
27 End If
28 Next I
29
30
2
3 Dim oDoc As HTMLDocument
4 Set oDoc = pDisp.Document
5
6 Dim oInput As HTMLInputElement
7 Set oInput = oDoc.getElementsByName("user")(0)
8 oInput.FireEvent "onkeypress"
9
10
11 解决方案2
12
13 Dim vDoc, vTag
14 Dim I As Integer
15 Set vDoc = WB1.Document
16 For I = 0 To vDoc.All.length - 1
17 If UCase(vDoc.All(I).tagName) = "INPUT" Then
18 Set vTag = vDoc.All(I)
19 If vTag.Type = "text" Then
20 Select Case vTag.Name
21 Case "username" '如果是用户名的那个框
22 vTag.Value = "用户名" '这个是用户名
23 vTag.onkeypress
24 End Select
25
26 End If
27 End If
28 Next I
29
30