我正在尝试单击网页上的锚元素。我正在使用这段代码:
For each anchor in HTMLDoc.anchors
If anchor.onclick = "validateForm(frmSearchEntry)" Then
anchor.click
exit for
End if
Next anchor
这是html的片段:
<tr>
<td height="35" align="right" nowrap>
<input type="hidden" name="aisposm01formReset" value="">
<a href="#" onclick="return resetForm(frmSearchEntry)"><img src="/Settlement/static/images/pbs/funcreset.gif" border="0"></a>
<a href="#" onclick="validateForm(frmSearchEntry)"><img src="/Settlement/static/images/pbs/funcsearch.gif" border="0" alt=""></a></td>
</tr>
<tr>
<td valign="bottom" nowrap>
<table>
<tr><td name="txtErrorMessage" class="error"></td></tr>
</table>
</td>
</tr>
但是,由于某种原因,当我尝试执行代码时,它只是飞过 for next 循环,就好像页面上的任何地方都没有锚元素一样。我不太确定我在这里做错了什么。