[RESOLVED] WebBrowser tag "A" click ?
Hi all,
I'm try click web link using for VB 6.0 but this is don't have a name or href..
I wrote the following HTML code:
<a onclick="javascript:etc">Text</a>
WebBrowser1.Document.getElementById("Text").Click (not work)
How do i do that using VB?
Thanks in advance, Hasan.
Sorry server is deleted my replays.. :confused:
Thanks for replays but my problem here:
PHP Code:
<a onclick="fbjs_sandbox.instances.a28768675863.bootstrap();return fbjs_dom.eventHandler.call([fbjs_dom.get_instance(this,28768675863),function(a28768675863_event) {a28768675863_do_job('12','08b5198e17f1ee375b6db12f8f09af1e2fa50590');},28768675863],new fbjs_event(event));return true;">Görev</a>
Help me please, thanks!
Hasan
Re: WebBrowser tag "A" click ?
<a onclick="javascript:etc">Text</a>
WebBrowser1.Document.getElementById("Text").Click
1) "Text" is not the ID
2) There is no ID and there is no name
3) etc has to be the name of a Java function and it must be etc(); with open/closing parens.
The below code snipit will work for a no-name, no-id hyperlink as long as your hyperlink (<a.......>Text</a>) is correct.
I do think, however, that your <a..........>Text</a> is incorrect. It should be something more like:
<a href="www.somesite.com" onclick="javascript:etc()">Text</a>
Add a reference to Microsoft HTML Object Library to your project
Code:
'
'
Dim HTML As HTMLDocument
Dim HyperLink As HTMLAnchorElement
Set HTML = WebBrowser1.Document
For Each HyperLink In HTML.links
'
' Set up some If....End If looking for what you want and when found click on it
'
If HyperLink.innerText = "Text" Then
HyperLink.Click
Exit For
End If
Next
'
'
Re: WebBrowser tag "A" click ?
Once you have included the id of the link like jmsrickland said you can use:
Code:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
WebBrowser1.Document.All("your link").Click
End Sub
Below is the whole code!
Code:
Private Sub Command1_Click()
WebBrowser1.Navigate "your site"
End Sub
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If URL = "your site" Then
WebBrowser1.Document.All("username").Value = txtUser.Text
WebBrowser1.Document.All("password").Value = txtPass.Text
WebBrowser1.Document.All("login").Click
End If
End Sub
Re: WebBrowser tag "A" click ?
Re: WebBrowser tag "A" click ?
Quote:
Originally Posted by getElementByID
Anyone help?
What are you talking about? You have already been given the answer to your problem. See posts #2 and #3
Re: WebBrowser tag "A" click ?
Thanks for help but not working posts #2 and #3 :confused:
Re: WebBrowser tag "A" click ?
Sure they work. You were told that your hyperlink has to be correct. I tested with your hyperlink (after I made it correct) and it worked just fine.
Now if you want help you need to reply with a better response than not working. That doesn't tell me anything. Did you add the reference I told you and did you correct your hyperlink? Give me something to go on. Your hyperlink as you have it posted is NOT clickable,
Re: WebBrowser tag "A" click ?
My "Görev" link not show and not click this code:
Private Sub Command1_Click()
Dim HTML As HTMLDocument
Dim HyperLink As HTMLAnchorElement
On Error Resume Next
Set HTML = WebBrowser1.Document
For Each HyperLink In HTML.links
txtcode.Text = txtcode.Text & HyperLink.innerText & vbCrLf
Next
End Sub
Thank again, Hasan
Re: WebBrowser tag "A" click ?
Thats because your "Görev" is NOT clickable. I already told you that. It is NOT a hyperlink until you make it a hyperlink like I told you in post #2
Here is what you have
Code:
<a onclick="fbjs_sandbox.instances.a28768675863.bootstrap();return fbjs_dom.eventHandler.call([fbjs_dom.get_instance(this,28768675863),function(a28768675863_event) {a28768675863_do_job('12','08b5198e17f1ee375b6db12f8f09af1e2fa50590');},28768675863],new fbjs_event(event));return true;">Görev</a>
Above is NOT a valid hyperlink and it is NOT clickable. You need to make it a hyperlink by adding some link reference to it like this
Code:
<a href="some.link.reference" onclick="fbjs_sandbox.instances.a28768675863.bootstrap();return fbjs_dom.eventHandler.call([fbjs_dom.get_instance(this,28768675863),function(a28768675863_event) {a28768675863_do_job('12','08b5198e17f1ee375b6db12f8f09af1e2fa50590');},28768675863],new fbjs_event(event));return true;">Görev</a>
NOTE
Before you start testing your stuff in VB with a WebBrowser control try testing it with IE and see what you will get. If it wont work in IE then it wont work in WebBrowser.
Re: WebBrowser tag "A" click ?
Okay, i'm using iMacros (Firefox addon) and it worked just fine.
TAG POS=1 TYPE=A ATTR=TXT:Görev (iMacros code)
Other method click for link ? Javascript function name or etc ..
Thank you.
Hasan
Re: WebBrowser tag "A" click ?
Well that still doesn't tell me anything. I have absolutely no idea what you are doing in your VB code and I have no idea what you are navigating to using your WebBrowser control but I believe that it isn't going to work because you are saying it is an addon for FireFox and FireFox is not IE and WebBrowser is IE. Now, does it work using IE or not. If it does not work using IE then it isn't going to work using WebBrowser. What else can I say
Re: WebBrowser tag "A" click ?
@ GetElementByID
Please upload the whole source code of the page you are talking about! Maybe then we can get the result you are getting and figure out how best to fix it.
Re: WebBrowser tag "A" click ?
Hi again,
i'm upload files copy this site:
http://www.jeomustafa.com/mytest.htm
Thanks, Hasan
Re: WebBrowser tag "A" click ?
Code:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
'
'
Dim HTML As HTMLDocument
Dim HTMLI As HTMLInputElement
Set HTML = WebBrowser1.Document
For Each HTMLI In HTML.getElementsByTagName("A")
If HTMLI.innerHTML = "Gorev" Then
HTMLI.Click
Exit Sub
End If
Next
'
'
End Sub
Re: WebBrowser tag "A" click ?
Dear jmsrickland and Nightwalker83 ;
It's okey.... Very very Thanks! :)
Re: WebBrowser tag "A" click ?
Quote:
Originally Posted by getElementByID
Dear jmsrickland and Nightwalker83 ;
It's okey.... Very very Thanks! :)
Did you manage you solve the problem? If so please mark the thread as "Resolved" and post the solution to the problem in the thread so other people may find it. :)
Re: WebBrowser tag "A" click ?
Okey thanks.. I give u repp!