Private Sub Form_Load()
WebBrowser1.Navigate sURL
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If URL = sURL Then
Dim Ele As Object
Set Ele = WebBrowser1.Document.getElementById("mobileno") '根据ID取得对象
Ele.Value = "www.m5home.com"
Set Ele = WebBrowser1.Document.getElementsByName("password") '根据Name取得对象
Ele(0).Value = "www.m5home.com"
Set Ele = WebBrowser1.Document.getElementsByName("operVerifyCode") '根据Name取得对象
Ele(0).Value = "www.m5home.com"
End If
End Sub
在使用getElementsByName取对象时要注意一点,就是NAME是可以有重复的,所以getElementsByName返回的是一个集合,其中包含了所有相同NAME的对象.
而ID是不可能有重复的,所以getElementById返回的就是一个单一对象.
摘自www.m5home.com