|
-
Feb 13th, 2009, 07:04 PM
#1
Thread Starter
New Member
[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..
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
-
Feb 13th, 2009, 08:38 PM
#2
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
'
'
Last edited by jmsrickland; Feb 14th, 2009 at 12:03 AM.
-
Feb 13th, 2009, 08:47 PM
#3
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
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 14th, 2009, 10:48 AM
#4
Thread Starter
New Member
Re: WebBrowser tag "A" click ?
-
Feb 14th, 2009, 11:16 AM
#5
Re: WebBrowser tag "A" click ?
 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
-
Feb 14th, 2009, 11:27 AM
#6
Thread Starter
New Member
Re: WebBrowser tag "A" click ?
Thanks for help but not working posts #2 and #3
-
Feb 14th, 2009, 11:31 AM
#7
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,
Last edited by jmsrickland; Feb 14th, 2009 at 11:34 AM.
-
Feb 14th, 2009, 11:52 AM
#8
Thread Starter
New Member
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
-
Feb 14th, 2009, 12:10 PM
#9
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.
Last edited by jmsrickland; Feb 14th, 2009 at 12:19 PM.
-
Feb 14th, 2009, 12:22 PM
#10
Thread Starter
New Member
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
-
Feb 14th, 2009, 12:33 PM
#11
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
-
Feb 14th, 2009, 06:02 PM
#12
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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 15th, 2009, 10:16 AM
#13
Thread Starter
New Member
Re: WebBrowser tag "A" click ?
Hi again,
i'm upload files copy this site:
http://www.jeomustafa.com/mytest.htm
Thanks, Hasan
-
Feb 15th, 2009, 11:36 AM
#14
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
-
Feb 15th, 2009, 12:30 PM
#15
Thread Starter
New Member
Re: WebBrowser tag "A" click ?
Dear jmsrickland and Nightwalker83 ;
It's okey.... Very very Thanks!
-
Feb 16th, 2009, 01:13 AM
#16
Re: WebBrowser tag "A" click ?
 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.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Feb 17th, 2009, 02:37 PM
#17
Thread Starter
New Member
Re: WebBrowser tag "A" click ?
Okey thanks.. I give u repp!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|