无法使用click()事件单击链接

时间:2017-09-05 05:30:43

标签: html vba

我正在尝试点击无序列表中的链接。无序列表在帧内,我不完全确定帧名称,所以我使用了递归搜索(从这个论坛获得的代码),

Dim elem2 As Object
Set elem2 = FindInputByName(ie.document, "0/2")
If Not elem2 Is Nothing Then
    elem2.Click 'THIS IS NOT WORKING
End If

  Function FindInputByName(document As Object, name As String) As Object
  Dim i As Integer, subdocument As Object, elem As Variant
  Set FindInputByName = Nothing

  For i = 0 To document.frames.Length - 1
    Set subdocument = document.frames.Item(i).document
    Set FindInputByName = FindInputByName(subdocument, name)
    If Not FindInputByName Is Nothing Then Exit Function
  Next i

  For Each elem In document.getElementsByTagName("a")
    If elem.ID = name Then
      Set FindInputByName = elem
      Exit Function
    End If
  Next elem

End Function

使用此代码no'点击'完成了。 我没有点击,而是尝试elem2.Focus elem2.FireEvent ("tree[i].onclick"),然后链接被选中,但没有再次点击。

html片段是,



<a id="0/2" style="padding-left: 13px;" href="#">GENERAL INFORMATION</a>
&#13;
&#13;
&#13;

但该元素有一个点击事件&#树; [i] .onclick&#39; 。 那么我该怎么做才能点击链接

提前致谢。

1 个答案:

答案 0 :(得分:0)

添加'application.wait'后,点击即将执行