Problem Programatically clicking links in WebBrowser control
Hi all i have html page loaded in to my webbrowser controle that looks like this:
<a href="http://www.somesite.com/recordds.wmt?page=31" title="Go to Next Page" onfocus="if(this.blur)this.blur();"
> next »</a>
I used the following code to click on it but it doesn't work . could you guys tell me what i am doing wrong ? Thanks
Code:
Private Sub Command8_Click()
For Each ele In WebBrowser1.Document.getelementsbytagname("a")
If ele.innertext = " next »" Then ele.Click
Next
End Sub
or
Code:
Private Sub Command8_Click()
For Each ele In WebBrowser1.Document.getelementsbytagname("a")
If ele.innertext = "next" Then ele.Click
Next
End Sub
Re: Problem Programatically clicking links in WebBrowser control
try
if instr(ele.innertext, "next") > 0 then ele.click
Re: Problem Programatically clicking links in WebBrowser control
Quote:
Originally Posted by
westconn1
try
if instr(ele.innertext, "next") > 0 then ele.click
Many thanks it worked well. Is there away that wait untill the next button load the page in webbrowser then do other things ? I tried this but it never loades the new next page only it loads whatever the page was in text1.text at start over and over . only at the end the next page get clicked once but even then text1 doesn't show the last new url!
could you help me fix this problem.Thanks
Code:
Private Sub Command9_Click()
For i = 0 To 4
TxtHTML = ""
RichTextBox1 = ""
WebBrowser1.Navigate Text1.Text
TxtHTML = Inet1.OpenURL(Text1.Text)
Label2.Caption = "Current Item:" & i
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
Text1.Text = ""
Command2_Click ' chap html
Command3_Click 'get items
For Each ele In WebBrowser1.Document.getelementsbytagname("a")
'If ele.innertext = "Go to Next Page" Then ele.Click
If InStr(ele.innertext, "next") > 0 Then ele.Click
Next
'wait for webbrowser to load then go next
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
Text1.Text = WebBrowser1.LocationURL
Next i
MsgBox "Complete"
End Sub